不允许用户使用免费电子邮件地址注册。必须只使用jQuery Validate Plugin
$("form").validate({
rules: {
username: {
required: true,
minlength: 2,
nofreeemail: true
}
},
messages: {
username: {
required: "Please enter a username",
minlength: "Your email must consist of at least 2 characters",
nofreeemail: "Please use your business email"
}
}
});
答案 0 :(得分:1)
添加新方法:
$.validator.addMethod('noemail', function (value) {
return /^([\w-.]+@(?!gmail\.com)(?!yahoo\.com)(?!hotmail\.com)(?!mail\.ru)(?!yandex\.ru)(?!mail\.com)([\w-]+.)+[\w-]{2,4})?$/.test(value);
}, 'Free email addresses are not allowed.');
rules: {
username: {
required: true,
minlength: 2,
noemail: true
}
},