Lets say i have fallowing email address-
闪闪发光@闪闪发光.com
how i can validate this email...so that user can not enter this type of开发者_如何学JAVA email address.
Thanks in advance!!!
var email="闪闪发光@闪闪发光.com"
var match=email.match(/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/gi)
if(match)
{
alert("correct");
}else
{
alert("incorrect");
}
Demo http://jsfiddle.net/usmanhalalit/JXJ5q/
Don't validate email addresses.. The best way to go about it is to simply look for an '@' and no spaces, and then on your server validate by doing a domainname lookup.
A standard regex should be able to help, as it will disallow any characters other than the ones you specify. May want to take a look at: JQuery validate e-mail address regex
精彩评论