Skip to content

Instantly share code, notes, and snippets.

@avireni
Created April 12, 2012 18:03
Show Gist options
  • Save avireni/2369696 to your computer and use it in GitHub Desktop.
Save avireni/2369696 to your computer and use it in GitHub Desktop.
Validate Email Address
$(document).ready(function() {
$('#txtEmail').blur(function() {
if(validateEmail('txtEmail'))
{
alert('Email is valid');
}
else
{
alert('Invalid Email Address');
}
});
});
function validateEmail(txtEmail){
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-z]{0,4}$/;
if(filter.test(a)){
return true;
}
else{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment