【发布时间】:2016-09-02 07:16:38
【问题描述】:
我想为所有包括非斜体字符的电子邮件地址编写正则表达式。
我试过了,结果是假的
请尽快提供正确的解决方案
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/xregexp/3.1.1/xregexp-all.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript">
var em = XRegExp('^([\\p{L}+|\\p{N}*][@][\\p{L}+][.][\\p{L}+])$'); // Please help me to correct it
jQuery(function(){
jQuery('input').blur(function(){
console.log(jQuery(this).val());
console.log(em.test(jQuery('#t1').val()));
});
});
</script>
<title></title>
</head>
<body>
Enter Name: <input type="text" name="t1" id="t1" class="kcd">
</body>
</html>
【问题讨论】:
-
非斜体字符?
-
<input type="email" /> -
可能是非意大利字母?由于字符类的错误使用,正则表达式显然搞砸了。必须是
XRegExp('^[\\p{L}\\p{N}]+@\\p{L}+[.]\\p{L}+$') -
问题与 jQuery Validate 插件无关。编辑标签。
标签: javascript regex validation xregexp