// A utility function that returns true if a string contains only // whitespace characters.//alert ("i'm at formValidator.js");function isblank(s) {    for(var i = 0; i < s.length; i++) {        var c = s.charAt(i);        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;    }    return true;}// This is the function that performs form verification. It is invoked// from the onsubmit event handler. The handler should return whatever// value this function returns.function verify(f) {    var msg;    var empty_fields = "";    var errors = "";    // Loop through the elements of the form, looking for all     // text and textarea elements that don't have an "optional" property    // defined. Then, check for fields that are empty and make a list of them.    // Also, if any of these elements have a "min" or a "max" property defined,    // verify that they are numbers and in the right range.    // If the element has a "numeric" property defined, verify that    // it is a number, but don't check its range.    // Put together error messages for fields that are wrong.    for(var i = 0; i < f.length; i++) {        var e = f.elements[i];                // FIELD VALUES        if (((e.type == "text") || (e.type == "textarea")) && !e.optional) {            // first check if the field is empty            if ((e.value == null) || (e.value == "") || isblank(e.value)) {                empty_fields += "\n          " + e.name;                continue;            }		}              	// make sure EMAIL in correct format              if ((e.name == "contactEmail") && (e.value != "")) {       		var emailPat = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;			var matchArray = e.value.match(emailPat);						if (matchArray == null) 			{				errors += "- Your email address seems incorrect.  Please try again (check the '@' and '.'s in the email address).\n\n";			}        	       }                      }        // Now, if there were any errors, display the messages, and    // return false to prevent the form from being submitted.     // Otherwise return true.    if (!empty_fields && !errors) return true;    msg = "The form was not submitted. Please correct and re-submit.\n\n";    if (empty_fields) {        msg += "- The following required information is missing:"                 + empty_fields + "\n";        if (errors) msg += "\n";    }    msg += errors;    alert(msg);    return false;}