// JavaScript Document// Create new main array. Good for empty text fieldsvar txt_name = new Array() // Form field names is listed first followed by a descriptive name to be show in the js pop up if left blanktxt_name[0] = new Array("F_NAME","First Name") txt_name[1] = new Array("L_NAME","Last Name") txt_name[2] = new Array("ADDRESS","Street Address")txt_name[3] = new Array("CITY","City")txt_name[4] = new Array("ZIP","Zip Code")// drop boxes to be validatedvar drop = new Array()drop[0] = new Array("STATE", "State")// check for blank text fieldsfunction missing_content(){	// check the regular text fields for empty content	var j;	var error_ct=0; // a counter variable for the errors;	var missing_empty = "";	// [01] CHECK THE TEXT FIELDS FROM THE ARRAY ABOVE	for (j=0; j<txt_name.length; j++){		if (document.contact[txt_name[j][0]].value == "") {			missing_empty+= txt_name[j][1] + "\n";		}	}	return missing_empty;}// function for the value of the dropdown fieldfunction drop_valid(drop_name) { // this will only work when the first value is set to: ""	var d;	var missing_drop = "";		for (d=0; d<drop_name.length; d++){		if (document.contact[drop_name[d][0]].selectedIndex == ""){			missing_drop+= drop_name[d][1] + "\n";		}	}	return missing_drop;}// email validationfunction checkEmail(myForm) {	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm)){		return (true)	}	return (false)}// BEGIN: FULL VALIDATIONfunction validation(){	var missing = "";	// ck for blank fields	missing = missing_content();	// make sure at least one of the phone numbers is filled:	my_home_ph = document.contact["PHONE_HOME"].value;	my_work_ph = document.contact["PHONE_WORK"].value;	if (my_home_ph == "" && my_work_ph == ""){		missing += "Phone number for home or work\n";	} 	// ck the drop down fields	miss_drop = drop_valid(drop);	missing += miss_drop;	// ck and validate the email address	email = checkEmail (document.contact["EMAIL"].value);		if (email == false){		missing+= "Invalid Email Address\n";	}// FINALE: is anything missing?	if (missing != ""){		missing_hdr = "The Following Errors Have Occurred:\n";		missing_ftr = "\n\n";		alert (missing_hdr + missing + missing_ftr);		return false;	} else {			return true;	}}