我正在使用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'
}
}
},发布于 2014-09-19 18:04:03
可以使用正则表达式排除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'
},
}
}我在这个小提琴中修改了引导验证示例,这样您就可以看到它的工作了:http://jsfiddle.net/pLt295eh/
https://stackoverflow.com/questions/25935299
复制相似问题