jQuery – validate email address

Below is the basic functionality to validate the email address:
First  add jQuery to your website then  code that will perform the validation when the submit button is clicked:
function isValidEmailAddress(emailAddress) {
var a = document.getElementById(txtEmail).value;
var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
if(filter.test(a)){
return true;
}
else{
return false;
}

};

Share this nice post:

One thought on “jQuery – validate email address

Leave a Reply

Your email address will not be published. Required fields are marked *