<- Back to Blog
Published: 11/12/2016

Preselect a country dropdown box based on a users location

There has been some research that suggests that for every field you add to a sign up form it adds another percentage point of users who will not complete the form. For this reason it is really important to only capture information you really need on a sign up form. We have created a really simple jQuery plugin to auto fill the users country based on their IP Address.

You can see the full demo here.

Essentially you include the plugin JS file:

<script src="localizeCountrySelect.js"></script>

Then run the extension on the country field on your form:

$('#country_select').countryLocalizeSelect();

And it will auto-magically fill in that field with the users country based on the IP Find database and their IP Address. This will work for both a text input field or a dropdown box. It does require jQuery to use.

Go here to see the demo and download the source