Skip to content

Instantly share code, notes, and snippets.

@lazypower
Created March 27, 2012 22:57
Show Gist options
  • Save lazypower/2221254 to your computer and use it in GitHub Desktop.
Save lazypower/2221254 to your computer and use it in GitHub Desktop.
LiveBall Zipcode Validator Extension
var LB = window.LB || {};
LB.validate = {
"form": document.liveballform,
"zip": document.liveballform.addresszip,
"message": 'The "ZipCode" is not a valid choice.',
"validArray": ["85001","85002","85003","85004","85005","85006","85007","85008","85009","85010","85011","85012","85013","85014","85015","85016","85017","85018","85019","85020","85021","85022","85023","85024","85025","85026","85027","85028","85029","85030","85031","85032","85033","85034","85035","85036","85037","85038","85039","85040","85041","85042","85043","85046","85050","85051","85053","85054","85055","85060","85061","85062","85063","85064","85065","85066","85067","85068","85069","85070","85071","85072","85073","85074","85075","85076","85078","85079","85080","85082","85083","85085","85086","85096","85098","85250","85251","85252","85253","85254","85255","85257","85258","85259","85260","85261","85266","85267","85269","85271","85280","85281","85282","85287","85301","85302","85303","85304","85305","85306","85307","85308","85309","85310","85311","85312","85318","85327","85329","85331","85335","85339","85345","85351","85353","85355","85363","85372","85373","85374","85375","85376","85377","85378","85379","85380","85381","85382","85383","85385","85387","85388","85395"]
,
isValidZipCode: function() {
if(this.zip.value != "" & this.validArray.indexOf(zip) <= 0)
{
return true;
}
else
{
return false;
}
},
init: function() {
this.form.onsubmit = function() {
if (!self.isValidZipCode()) {
alert(self.message);
return false;
}
else {
return true;
}
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment