Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$('#zipcode').bind('keyup change', function(e) {
if ($(this).val().length > 4) {
var ort = $('#city');
$.getJSON('http://www.geonames.org/postalCodeLookupJSON?&country=DE&callback=?', {postalcode: this.value }, function(response) {
if (response && response.postalcodes.length && response.postalcodes[0].placeName) {
ort.val(response.postalcodes[0].placeName);
}
})
} else {
$('#city').val('');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.