$('#ad_pd_form').bootstrapValidator({
fields: {
ad_pd_url: {
validators: {
notEmpty: {
message: 'Please enter a Valid URL'
}
}
}
}
})我需要限制用户在文本框中输入特殊字符。我使用bootstrap验证器来验证上面代码中的表单。仅允许用户输入URL。
如何限制输入的特殊字符?
发布于 2016-04-26 13:29:31
使用正则表达式限制验证器中的特殊字符
var nospecial=/^[^*|\":<>[\]{}`\\()';@&$]+$/;
validators: {
notEmpty: {
message: 'Please enter a Valid URL'
},
regexp: {
regexp: nospecial,
message: ' '
}
}发布于 2016-04-26 13:31:51
$('#ad_pd_form').bootstrapValidator({
fields: {
ad_pd_url: {
validators: {
notEmpty: {
message: 'Please enter a Valid URL'
},
// Url Validation
uri: {
message: 'The website address is not valid'
}
}
}
}
})https://stackoverflow.com/questions/36855837
复制相似问题