JavaScript Regular Expression Email Validation

Posted by azamsharp on Stack Overflow See other posts from Stack Overflow or by azamsharp
Published on 2009-06-02T16:40:50Z Indexed on 2010/06/09 14:52 UTC
Read the original article Hit count: 237

Filed under:
|

For the love of God I am not getting this easy code to work! It is always alerting out "null" which means that the string does not match the expression.

var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$"; 

function isEmailAddress(str) {

    str = "[email protected]";      

    alert(str.match(pattern)); 
    return str.match(pattern);    

}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex