多封电子邮件的电子邮件验证(以逗号分隔) [英] Email Validation for multiple emails (comma separated)
问题描述
我目前在js中使用以下正则表达式进行电子邮件验证,
其中电子邮件地址可以用逗号分隔或
分号。然而,问题在于我可以输入两封电子邮件
(作为连续播放,没有逗号或分号),只要它以
$ b $结尾b三个字符域,它被认为是有效的。
我想知道是否有办法制作逗号或分号
如果是第二封电子邮件必须地址已存在?
非常感谢任何帮助 - 路易斯
这是脚本:
function checkEmailForErrors(表格,字段){
var emailFilter2 = /(([a-zA-Z0-9 \-?\。?] +)@(([a-zA-Z0-9 \\ \\ -_] + \。)+)([az]
{2,3})(\ W?[,;] \ W?(?!$))?) + $ / i;
var emailValue2 = eval(" document。" + Form +"。" + Field +" .valu e");
if(!(emailFilter2.test(emailValue2))){
返回false;
} else {
返回true;
}
}
Hi,
I currently am using the following regex in js for email validation,
in which the email addresses can be separated by commas or
semicolons. The problem, however, lies in that I can type two emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.
I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis
Here is the script:
function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}
推荐答案
))?)+
/ i;
var em ailValue2 = eval(" document。" + Form +"。" + Field +" .valu e");
if(!(emailFilter2.test(emailValue2))){
返回false;
}否则{
返回true;
}
}
/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}
您可以尝试使用以下正则表达式:
/^ [A-Z0-9 \。 % - ] + @ [A-Z0-9\ .-] + \ [AZ] {2,4}(:(:?[;] [A-Z0-9\ ._% - ] + @ [A-
Z0-9 \ .-] +))?
You can try to use the following regular expression:
/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-
Z0-9\.-]+))?
这篇关于多封电子邮件的电子邮件验证(以逗号分隔)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!