Several years later, I am also wondering about this.
Already done a couple of years ago: MktoForms2 :: Google Places Zip v1.0.2
There are other APIs (some a lot less complex and just as accurate) but this uses the Google Maps Geocoder.
Obvs. you'd want to fine-tune the interaction between auto-filled fields and manually entered fields... this is just a simple demo.
Thanks for this, Sanford. As always your help is ultra appreciated.
Hook up your external service to the field using the forms API
e.g. with fictional service
function postalCodeLookup(postalCode){
$.ajax({
method:'POST',
url: '//your.webhook.com/endpoint',
data: postalCode, // you might need an api key or access token
dataType:'json', // if data is returned as json
success:function(data){
$('#City').val(data['city']); // how the data is returned varies depending on your webservice
$('#State').val(data['state']);
console.log("Lookup success");
},
error: function(xhr) {
console.log("Lookup error");
}
});
}
MktoForms2.whenReady(function (form) {
$('#PostalCode').change(function(){
postalCodeLookup($(this).val());
});
});
Obviously you will need to know some coding to deploy the service
Hi Edwin
Did you ever find a solution to this?