Vaildate Email Address

Description: Simple regular expression based algorithm for determining if an email address is valid. Great for signup forms or verifying usernames which might be a person's email.
Tested Platform: All Modern Browsers
Language: JavaScript
function validateEmail(emailAddress) {
    return /^[a-z0-9_-][a-z0-9._-]+@([a-z0-9][a-z0-9-]*\.)+[a-z]{2,6}$/i.test(emailAddress);
}

Submitted: December 24, 2012

Return to the snippets listing