
//check to see if it is a valid zipcode
function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter a 5 digit zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}

function validateOnSubmit() {
    var elem;
    var errs=0;
		if (!validatePresent(document.forms.boroughfind.boroughchs,  'inf_boroughchs'))        errs += 1; 
	//alert(num_missing);
	
	if (errs>1)  alert('There are fields which need correction before sending');
    if (errs==1) alert('There is a field which needs correction before sending');
	if (errs==0) document.forms.boroughfind.submit();
    return (errs==0);
	};

