// JavaScript Document//function to check empty fieldsfunction isEmpty(strfield1, strfield2, strfield3, strfield4) {//change "field1, field2 and field3" to your field namesstrfield1 = document.forms[0].name.value strfield2 = document.forms[0].subject.valuestrfield3 = document.forms[0].hearabout.valuestrfield4 = document.forms[0].eventlocation.value  //first name field    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')    {    alert("\"Name\" is a required field.\nPlease amend and retry.")    return false;    }  //last name field     if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')    {    alert("\"Subject\" is a required field.\nPlease amend and retry.")    return false;    }  //phone field     if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')    {    alert("\"How did you hear about us\" is a required field.\nPlease amend and retry.")    return false;    }			//location field     if (strfield4 == "" || strfield4 == null || strfield3.charAt(0) == ' ')    {    alert("\"Event Location\" is a required field.\nPlease amend and retry.")    return false;    }	    return true;}//function to check valid email addressfunction isValidEmail(strEmail){  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;  strEmail = document.forms[0].email.value;   // search email text for regular exp matches    if (strEmail.search(validRegExp) == -1)    {      alert('A valid e-mail address is required.\nPlease amend and retry');      return false;    }     return true; }//function that performs all functions, defined in the onsubmit event handlerfunction check(form){if (isEmpty(form.field1)){ if (isValidEmail(form.email)){  if (isEmpty(form.field2)){    if (isEmpty(form.field3)){			if (isEmpty(form.field4)){		  return true;		  				}			}	  	}  	}}return false;}
