ZipCode Object

wxdqz

New Member
I have gone at this several different ways and can't get it to work.

I have a script which loads the zipcodes for Ohio into a javascript object, then when someone enters a zipcode on the page onBlur triggers a function which searches the Object to find the city and state based on the zipcode and then prefills the appropriate text boxes on the form.
THIS WORKS GREAT as long as you live in Ohio.

Problem: If you enter a zipcode for a different state I can't seem to evaluate to trigger an alert.

Obviously it doesn't find an instance in the object. So I have tried to evaluate. For example--

function zipLookup(){
var zipc = window.document.submitq.txtZipCode.value;
var city = zipArray[zipc].city;

if(city == null || city =="undefined"){
alert("Not an Ohio ZipCode");
return false;
}
}

I can never get this thing to alert! Thanks for any help!!
 
Top