具有JQuery Vaildate的带有其他域的电子邮件地址的正则表达式 [英] RegEx of email address with additional domains with JQuery Vaildate
本文介绍了具有JQuery Vaildate的带有其他域的电子邮件地址的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要验证具有其他域的电子邮件地址.我目前使用@email.com
验证正常的电子邮件,但是我需要验证具有@email.email.com
的电子邮件.我对RegEx不够熟悉.
I need to validate an email address with extra domains. I validate currently a normal email with @email.com
, but I need to validate an email that has @email.email.com
. I am not familiar with RegEx enough.
$.validator.addMethod('matches', function (value, element, param) {
return this.optional(element) || value.match(param);
},
'Please enter a valid value.');
$(function() {
$("form").validate({
rules: {
email: {
required: true,
email: true,
matches: '.+@email.com'
}
}, messages: {
email: {
matches: 'Must be a email.com e-mail address.'
}
}
});
});
推荐答案
此方法适用于jquery验证,以确认电子邮件属于该组织.我真的很近,但是我认为这不需要一些事情.
This worked for jquery validate to validate that email belongs to the organization. I was really close, but I didn't think it would need a few things.
(.+@+[A-Za-z0-9._-]+\\.email.com$)|(.+@email.com$)
这篇关于具有JQuery Vaildate的带有其他域的电子邮件地址的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文