function validEmail(email, fieldNo) {	invalidChars = "\/:,;|[]{}'><?"	for (i=0; i<invalidChars.length; i++) {		badChar = invalidChars.charAt(i);		if (email.indexOf(badChar,0) != -1) {			alert('The email address ' + fieldNo + ' contains an invalid character: '+badChar);			return false;			}		}	atPos = email.indexOf("@",1)	if (atPos == -1) {			alert('The email address ' + fieldNo + ' is incomplete: missing "@"');			return false;		}	if (email.indexOf("@",atPos+1) != -1) {			alert('The email address ' + fieldNo + ' contains a more than 1 (one) @ character');			return false;		}	periodPos = email.indexOf(".",atPos)	if (periodPos == -1) {			alert('The email address ' + fieldNo + ' is incomplete: missing "."');			return false;	} 	if (periodPos+3 > email.length) {			alert('The email address ' + fieldNo + ' is incomplete: missing ".com/ net /org ?"');			return false;	}		return true}function addresp_valid(form) {	// email has been entered and valid	if ((form.AddRespAddress1.value != "")) {		if (validEmail(form.AddRespAddress1.value, "1") == false) {			return false;		}	}		if ((form.AddRespAddress2.value != "")) {		if (validEmail(form.AddRespAddress2.value, "2") == false) {			return false;		}	}		if ((form.AddRespAddress3.value != "")) {		if (validEmail(form.AddRespAddress3.value, "3") == false) {			return false;		}	}		if ((form.AddRespAddress4.value != "")) {		if (validEmail(form.AddRespAddress4.value, "4") == false) {			return false;		}	}		if ((form.AddRespAddress5.value != "")) {		if (validEmail(form.AddRespAddress5.value, "5") == false) {			return false;		}	}		if ((form.AddRespAddress6.value != "")) {		if (validEmail(form.AddRespAddress6.value, "6") == false) {			return false;		}	}		if ((form.AddRespAddress7.value != "")) {		if (validEmail(form.AddRespAddress7.value, "7") == false) {			return false;		}	}		if ((form.AddRespAddress8.value != "")) {		if (validEmail(form.AddRespAddress8.value, "8") == false) {			return false;		}	}		if ((form.AddRespAddress9.value != "")) {		if (validEmail(form.AddRespAddress9.value, "9") == false) {			return false;		}	}		if ((form.AddRespAddress10.value != "")) {		if (validEmail(form.AddRespAddress10.value, "10") == false) {			return false;		}	}		if ((form.AddRespAddress11.value != "")) {		if (validEmail(form.AddRespAddress11.value, "11") == false) {			return false;		}	}		if ((form.AddRespAddress12.value != "")) {		if (validEmail(form.AddRespAddress12.value, "12") == false) {			return false;		}	}		if ((form.AddRespAddress13.value != "")) {		if (validEmail(form.AddRespAddress13.value, "13") == false) {			return false;		}	}		if ((form.AddRespAddress14.value != "")) {		if (validEmail(form.AddRespAddress14.value, "14") == false) {			return false;		}	}		if ((form.AddRespAddress15.value != "")) {		if (validEmail(form.AddRespAddress15.value, "15") == false) {			return false;		}	}	if ((form.AddRespAddress16.value != "")) {		if (validEmail(form.AddRespAddress16.value, "16") == false) {			return false;		}	}	if ((form.AddRespAddress17.value != "")) {		if (validEmail(form.AddRespAddress17.value, "17") == false) {			return false;		}	}	if ((form.AddRespAddress18.value != "")) {		if (validEmail(form.AddRespAddress18.value, "18") == false) {			return false;		}	}	if ((form.AddRespAddress19.value != "")) {		if (validEmail(form.AddRespAddress19.value, "19") == false) {			return false;		}	}	if ((form.AddRespAddress20.value != "")) {		if (validEmail(form.AddRespAddress20.value, "20") == false) {			return false;		}	}}// This function performs form validation by // looping through the elements of the form// looking for any in the 'required' or // 'numeric' class//// This function is passed a reference to the// form (document._NotesFormName)function validateFields(theForm) 	{	// Initialise variables	var msg;	var empty_fields = "";	var numeric_fields = "";		// The next 3 variables are used when	// checking checkboxes or radio buttons.	possibleError = new Object();	var noError = "";	var x = 0;			// Loop through the elements of the form,	// looking for all the text and textarea elements	// in the 'required' class. Then, check for the 	// fields that are empty and make a list of them.	// Put together an error messge for fields that	// fail validation.	for(var i = 0; i < theForm.length; i++) 		{		var e = theForm.elements[i];				if (e.className.indexOf( "required") != -1) 			{			// Check for the type of field and then			// edit accordingly.			if ((e.type == "text" || e.type == "textarea") && (e.value == null || e.value == "")) 				{				empty_fields += "\n         " + e.title;				continue;				}						if (e.type == "select-multiple" && e.selectedIndex == -1) 				{				empty_fields += "\n         " + e.title;				continue;				}						// The first option in the select-one			// list is the "-Select one-" and should 			// produce an error.			if (e.type == "select-one" && e.selectedIndex == 0) 				{				empty_fields += "\n         " + e.title;				continue;				}							// Process each checkbox and radio button.			// If checked, add to the no error list, otherwise			// add to the possible error list			if (e.type == "radio" || e.type == "checkbox") 				{				if (e.checked == false) 					possibleError[x++] = e.title;				else					noError += e.title				}			} // End of check for required fields				// Check for numeric fields.		if (e.className.indexOf( "numeric") != -1 && (e.type == "text" || e.type == "textarea")) 			{			if ( !isNumber( e.value )) 				{				numeric_fields += "\n         " + e.title;				}			} // End checking for numerics		} // End looping through from elements				// Loop through the possible errors in 		// radion buttons and checkboxes and 		// find out which are actual errors.		for (count in possibleError)			{			if (noError.indexOf (possibleError[count])  == -1)				{				empty_fields += "\n         " + e.title + possibleError[count];				noError += possibleError[count];				}			}				// If there were any errors, display		// the error message, otherwise give the 		// user the option of submitting the form.		if ( !empty_fields && !numeric_fields)			{			if (confirm("Do you wish to submit your answers now?"))				{				theForm.submit();				}			}		else			{						msg =	"________________________________\n\n" ;			msg +=	"The form was not submitted because of\n" ;			msg +=	"the following errors. Please correct\n" ;			msg +=	"these error(s) and re-submit.\n" ;			msg +=	"________________________________\n\n" ;						if (empty_fields)				{				msg += "These required fields are empty:\n" ;				msg += empty_fields + "\n\n" ;				}							if (numeric_fields)					{				msg += "These following numeric fields have\n" ;				msg += "character data:\n" ;				msg += numeric_fields + "\n\n" ;				}						alert(msg);			}		}	// Check if a string is a number	// Numbers have 0-9, "-", and "."	function isNumber (inputNum)		{							decimalPoint = false ;				for (var i = 0; i < inputNum.length; i++)			{			var oneChar = inputNum.charAt(i) ;			if (i == 0 && oneChar == "-")				{				continue ;				}							if (oneChar == "-" && !decimalPoint)				{				decimalPoint = true ;				continue ;				}							if (oneChar < "0" || oneChar > "9")						{				return false ;				}			} // End of looping through inputNum			return true ;		}