//function to check empty fields

function isEmpty(strfield1, strfield2, strfield3) {


//change "field1, field2 and field3" to your field names
strfield1 = document.forms[0].name.value 
strfield2 = document.forms[0].phone.value
strfield3 = document.forms[0].enquiry.value

  //Name field
    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert("Your name is required")
    return false;
    }

  //Phone field 
    if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
    {
    alert("A valid contact number is required")
    return false;
    }

  //Make field 
    if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')
    {
    alert("What are you enquiring about?")
    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.');
      return false;
    } 
    return true; 
}


//function that performs all functions, defined in the onsubmit event handler

function check(form){
if (isEmpty(form.field1)){
  if (isEmpty(form.field2)){
    if (isEmpty(form.field3)){
		if (isValidEmail(form.email)){
		  return true;
		}
	  }
  }
}
return false;
}

