Javascript 多电子邮件正则表达式验证
通常简单电子邮件的验证是:
/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
这将验证电子邮件,例如 [email protected]< /a>
但是如何验证电子邮件是否是多个?
entry 1: [email protected], [email protected], [email protected]
entry 2: [email protected] , [email protected] , [email protected]
entry 3: [email protected], [email protected] , [email protected]
entry 4: [email protected]
该电子邮件是用户可能输入的条目。有时还期望有 2 或 3 或 4 封或更多电子邮件。
感谢您的回答。
Normally validation of simple email is:
/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
This will validate email like [email protected]
But how to validate if email is multiple?
entry 1: [email protected], [email protected], [email protected]
entry 2: [email protected] , [email protected] , [email protected]
entry 3: [email protected], [email protected] , [email protected]
entry 4: [email protected]
This emails is a possible entries that user will input. Also expect thier is 2 or 3 or 4 or more emails sometimes.
Thanks for the answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
用逗号分割电子邮件并验证条目
getEmails() 从页面获取电子邮件,并验证针对电子邮件运行正则表达式
Split the emails on a comma and validate the entries
Where getEmails() gets the emails from the page, and validate runs your regex against the emails
尝试
接受逗号和分号作为分隔符
try this
accept both comma and semicolon as separator
这是一个用于多个邮件验证的正则表达式,无需拆分
https://regex101.com/r/TUXLED/1< /a>
Here is a regex for multiple mail validation without split
https://regex101.com/r/TUXLED/1
您应该能够用逗号分隔条目,然后根据正则表达式测试各个电子邮件子条目。
在测试任何已剥离的电子邮件子字符串之前,您可能还需要修剪所有空格。
You should be able to split the entry by commas, and then test the individual email subentries against the regexp.
You might also want to trim any whitespace before testing any of the stripped email substrings.
尝试使用 jquery 验证:
Try this for jquery validation:
这是 JavaScript 代码,用于检查电子邮件是否包含多个 @ 字符
另一种方法是使用电子邮件的标准模式
This is javascript code to check if email contains more than one @ characters
Alternate way is by using the standard pattern of the email
ruby 动态数据中的 Javascript 多电子邮件正则表达式验证
Javascript multiple email regexp validation in ruby dynamic data