Home How do I add default (Default to browser country) country code before the mobile number in MVC ASP.NET?
Reply: 1

How do I add default (Default to browser country) country code before the mobile number in MVC ASP.NET?

Neeraj Kumar
1#
Neeraj Kumar Published in 2017-11-13 17:24:05Z

I have got a Textbox accepting mobile number. How do I add default (Default to browser country) country code before the mobile number?

I am using MVC ASP.NET

Oswaldo
2#
Oswaldo Reply to 2017-11-13 17:55:47Z

You can use the service, http://ipinfo.io, to detect the country by user's IP (The location will generally be less accurate than the native geolocation details, but it doesn't require any user permission). It will give you the client IP, hostname, geolocation information (city, region, country, area code, zip code etc) and network owner.

$.get("https://ipinfo.io", function(response) {
   console.log(response.city, response.country);
}, "jsonp");

Here's a more detailed JSFiddle example that also prints out the full response information, so you can see all of the available details: http://jsfiddle.net/zK5FN/2/

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.326871 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO