function isEmpty(strfield1, strfield2) {

strfield1 = document.forms[0].name.value 
strfield2 = document.forms[0].email.value

    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert("Please enter your name.")
    return false;
    }

    if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
    {
    alert("Please enter your email address.")
    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 (isEmpty(form.field2)){
		if (isValidEmail(form.email)){
		  return true;
		}
  }
}
return false;
}
