E-mail Validation

Saranya Boopathi
Posted by Saranya Boopathi under JavaScript category on | Points: 40 | Views : 1324
E-mail Validation in JavaScript:

function EmailvalidateForm()
{
var x=document.forms["myForm"]["E_mail"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}

<form name="myForm" action="demo_form.asp" onsubmit="return EmailvalidateForm();" method="post">
E_mail: <input type="text" name="E_mail">
<input type="submit" value="Submit">
</form>

Comments or Responses

Login to post response