 function checkEmail(fld)
 {
  inputValue = fld.value;
  var ri = /^[\w\-\.]+@[\w\-\.]+\.[\w]{2,}$/;
  return (!ri.test(inputValue))
 }

 function CheckForm (theForm)
 {
  var errmsg = "The following error(s) occured while trying to process the form:\n";
  errmsg += "__________________________________________________\n\n";
  var badmail = " is not valid e-mail address.\n";
  var passed = true;
  
   if (theForm.txtyourname.value.length == 0) 
   { 
    passed = false;
    errmsg += "You need to enter your Name.\n";
   }
   if (theForm.txtaddress.value.length == 0) 
   { 
    passed = false;
    errmsg += "You need to enter your Address.\n";
   }
   if (theForm.txthomephone.value.length == 0) 
   { 
    passed = false;
    errmsg += "You need to enter your Home phone number.\n";
   }
   if (theForm.txtcompany.value.length == 0) 
   { 
    passed = false;
    errmsg += "You need to enter your Company Name.\n";
   }
   if (theForm.txtjobtitle.value.length == 0) 
   { 
    passed = false;
    errmsg += "You need to enter your Job Title.\n";
   }
   if (theForm.txtreferredby.value.length == 0) 
   { 
    passed = false;
    errmsg += "You need to enter who referred us to you.\n";
   }
   if (theForm.txtemail.value.length == 0)
   { 
    passed = false;
    errmsg += "You need to enter your Home Email address.\n";
   }
   else
   {
		if (checkEmail(theForm.txtemail))
		{
			passed = false;
			errmsg += theForm.txtemail.value + badmail
		}
   }
   if (passed == false) 
   {
	   alert (errmsg) 
   }
   return(passed); 
}
