|
The IsEmail Function check if the text in the Element (textbox) is Email or not . Please note
the parameter passed is a Textbox Element. if u want to pass text. u can avoid line 1
inside the function and change line3 to regex.test(elem);
function IsEmail(elem)
{
var field = elem.value;
var regex = new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$");
return regex.test(field);
}
Usage
if(IsEmail(document.getElementById("<%=txtPrimaryEMail.ClientID%>")))
{
alert("Valid EMail");
}
|