1.html中表单初始化
<script>
//表单验证初始化
$('#wx_pay_account_form_id').bootstrapValidator({
message : 'This value is not valid',
feedbackIcons : {
required : 'glyphicon glyphicon-asterisk requiredStar',
valid : 'glyphicon glyphicon-ok',
invalid : 'glyphicon glyphicon-remove',
validating : 'glyphicon glyphicon-refresh'
},
fields : {
wx_mchID_name : {
validators : {
notEmpty : {
message : 'mchID不能为空'
}
}
},
}
});
</script>
2、js中校验
var bootstrapValidator = $("#device_setting_name_form_id").data('bootstrapValidator');
bootstrapValidator.validate();
if (!bootstrapValidator.isValid()) {
return;
}
3、js中重置css
$("#device_setting_name_form_id").data("bootstrapValidator").resetForm();