simple method that checks text is email with regular expression
Posted
by user223863
on Stack Overflow
See other posts from Stack Overflow
or by user223863
Published on 2010-06-07T16:03:46Z
Indexed on
2010/06/07
16:12 UTC
Read the original article
Hit count: 175
JavaScript
|validation
Can't believe how difficult this seems to be all I want to is to validate a user inout using javascript to make sure that it is an email address. But can't get it to work:
I am using:
//validates a regulaer expression
Utilities2.prototype.validateEmail = function(stringToValidateArg)
{
alert('about to check regexp');
var regExpPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
alert(regExpPattern.test(stringToValidateArg));
}
But this always returns false, any ideas why is it because of the regular expression?
© Stack Overflow or respective owner