Regular expression for Email validation

Susanthampy
Posted by Susanthampy under JavaScript category on | Points: 40 | Views : 2396
Script:

var email=document.getElementById("txtEmail").value;
var emailfilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
var illegalchars = /[\(\)\<\>\,\;\\\\"\[\]]/;

if (!emailfilter.test(email)) {
alert("Invalid email");
document.getElementById("txtEmail").focus();
return false;
}
else if (email.match(illegalchars)) {
alert("Invalid email address");
document.getElementById("txtEmail").focus();
return false;
}
else
{
return true;
}

Comments or Responses

Posted by: T.saravanan on: 4/28/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,

Kindly post your code inside the code tag.
Posted by: Susanthampy on: 4/29/2011 Level:Bronze | Status: [Member] [MVP] | Points: 10
Nxt time... definitely
Posted by: T.saravanan on: 5/1/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Ok.
Just go and edit this code add the code inside the code tag.
Posted by: Susanthampy on: 5/4/2011 Level:Bronze | Status: [Member] [MVP] | Points: 10
Done

Login to post response