开发者

How to validate email address containing non-english (UTF-8) character in Javascript

开发者 https://www.devze.com 2023-04-06 14:09 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消