我使用BootstrapValidator验证我的电子邮件输入框。它工作得很好,但我想要破坏某个电子邮件域名" @ test.com"从验证,我该怎么做?
这是代码:
email: {
message: 'Your email must be in the format "example@domain.com"',
validators: {
notEmpty: {
message: 'Your email is required and cannot be empty'
},
emailAddress: {
message: 'The value is not a valid email address'
}
}
},
答案 0 :(得分:1)
您可以使用正则表达式排除test.com域:
email: {
validators: {
notEmpty: {
message: 'The email address is required and cannot be empty'
},
emailAddress: {
message: 'The email address is not a valid'
},
regexp: {
regexp: /^((?!@test\.com).)*$/,
message: 'The test.com domain is invalid'
},
}
}
我已经修改了这个小提琴中的bootstrap验证示例,因此您可以看到它正常工作: http://jsfiddle.net/pLt295eh/