﻿// Javascript validation functions
// http://www.designplace.org/


//function to check empty fields

function isEmpty(Field,Name) {

var strfield1 = Field.value 

  //name field
    if (strfield1 == "")
    {
    alert(Name +  " is a mandatory field.\n")
    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(){
    if (isEmpty(theForm.name, "ctl00$Name")) {
        if (isEmpty(theForm.email, "ctl00$Email")) {    
		if (isValidEmail(theForm.email)){
		  return true;		
	  }
  }
}
return false;
}
