Email Id validation in Javascript

var EmailId=document.getElementById("<%=txtEmailID.ClientID %>").value;
if (EmailId.trim() != "") {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (reg.test(EmailId) == false) {
        alert('Invalid Email Address');
        return false;
    }
}

Here txtEmailID is the textbox for input Email Id.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s