|
|
|
[
Permlink
| « Hide
]
Dan Hardiker - 02/Feb/08 05:17 PM
The logic is as follows, feel free to suggest improvements!
My regex-fu is far too weak to critique meaningfully, sorry. From my limited understanding of email validation regexes, your proposal looks fairly complete, but by no means (as I understand it) definitive
I think it would be much simpler to add a check to make sure spaces aren't used! It looks like this now:
isEmail: function (str) {
// Check to see if it contains a space
if (str.indexOf(" ") > -1) return false;
// If regular expressions aren't supported
if (!FormMailNGUtil.regexSupported())
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
// If they are
var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
return (!r1.test(str) && r2.test(str));
}
|
||||||||||||||||||||||||||||||||||||||||||||