﻿function validateEmail(theForm) {
if (theForm.cname.value.length <= 4) {alert("you must enter your name");theForm.cname.focus();return false;  };
if (theForm.cemail.value.length <= 4) {alert("you must enter your email");theForm.cemail.focus(); return false; };
  var str = theForm.cemail.value; // email string
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
    //alert("Thank your for your feedback."); // this is optional
    return true;
  } else {
  alert("\"" + str + "\" is an invalid e-mail!"); // this is also optional
  theForm.cemail.focus();
  theForm.cemail.select();
  return false;}
  }