Validate Email ID using regular Expression (javascript function)

Rajni.Shekhar
Posted by Rajni.Shekhar under JavaScript category on | Points: 40 | Views : 1511
function ValidateEmailID()
{
var id=document.getElemetById("txtEmail");
if(id.value != "")
{
var emailVal=id.value;
var emailPettern=/^[a-z0-9]([a-z0-9_\-\'\.]*)@([a-z0-9\-]+)(\.[a-z]{1,3})(\.*)$/i;
if (emailVal.search(emailPettern) == -1)
{
alert("Enter valid email ID in format : xxx@abc.com")
id.focus();
}
}
}

Comments or Responses

Posted by: Self-Innovator on: 4/4/2012 Level:Bronze | Status: [Member] | Points: 10
Nice Codes..

Keep posting

Login to post response