Monday, June 2, 2008

javascript:Email Check

var emailexp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

Usage

if(document.getElementById(FinalControlID10).value.trim() =="")
{
alert("Please enter Email Address.");
document.getElementById(FinalControlID10).focus();
return false;
}
else if(emailexp.test(document.getElementById(FinalControlID10).value.trim()) == 0)
{
alert("Please enter a valid Email Address.");
document.getElementById(FinalControlID10).focus();
return false;
}

No comments: