Link to home
Start Free TrialLog in
Avatar of SeanNij
SeanNijFlag for South Africa

asked on

Email Validation Using JavaScript in ASP

Hi all,

Very very new to ASP and Java. With the help of much reading on EE I have managed to get some validation working for my ASP development. However, in trying to get my Email validation to working using JavaScript and RegEx, it falls apart.

The validiation works for the blank LMFullName but not for the Email Address.

I'm sure its got to do with my JavaScript - help....
<script language="JavaScript" type="text/javascript">
<!-- JavaScript to validate form and disable submit button
function isEmail(strValue){
      var objRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      return objRegExp.test(strValue);
}
 
function CheckForm(form)
{
 
  document.getElementById("LMFullName").innerHTML = "";
	
	if (form.txt_LMFullName.value == "")
	{
	  document.getElementById("LMFullName").innerHTML = "<font color=#FF0000>*";
	  form.txt_LMFullName.focus();
	  return false;
	}
  
 
    if(!isEmail(form.txt_LMEmailAddress.value))
	{
       err += "- e-mail Addresse\n";
       if(form.txt_LMEmailAddress.value == "") focusField = "email";
     }
       if(err != ""){
	   document.getElementById("EmailAddress").innerHTML = "<font color=#FF0000>*";
       form.txt_LMEmailAddress.focus();
       return false;
       }
  
  
  document.form1.button_Save.disabled=true;
  document.form1.button_Save.value="Done.";
  return true ;
}
//-->
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dlastlee
dlastlee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SeanNij

ASKER

Thanks for that - spilt the points as the dlastlee solution did fix my prob, but HonorGods suggestion really works nicely in my limited javascript coding...so thanks guys!
You are very welcome.  Thanks for the assist, and the points.

Good luck & have a great day.