bootstrapValidator验证隐藏的input
解决方法:
1.html标签如下
<input type="text" class="form-control" readonly>
<input type="hidden" id="type" name="type" class="form-control" >
2.赋值时调用change方法
$("#type").val(this.form.type).change();
3.验证配置加 excluded:[":disabled"]和trigger:"change"
$('#form').bootstrapValidator({
message: '格式不正确',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
excluded:[":disabled"],
fields: {
type: {
message: '分类不能为空',
trigger:"change", //关键配置
validators: {
notEmpty: {
message: '分类不能为空'
},
stringLength: {
max: 200,
message: '不能超过200个字'
},
}
},
}
});