bootstrapValidator如何重新初始化
2016-03-28 13:25
686 查看
在大多数情况下bootstrapValidator是不需要重新初始化的,极少数情况下则需要把动态增加的控件也纳入到验证中来。这时如何做?
//先销毁
$("#yourForm").data('bootstrapValidator').destroy();
$('#yourForm').data('bootstrapValidator', null);
//再重新初始化
$("#yourForm").bootstrapValidator({
message: '没有验证',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
message: '名字没有验证',
validators: {
notEmpty: {
message: '名字为必填项不能为空'
}
}
}
// add your_form_field here
}
}).on('success.form.bv', (e) {
// 阻止默认事件提交
e.preventDefault();
}););
参考资料:http://stackoverflow.com/questions/25639287/bootstrapvalidator-how-do-you-add-and-remove-validators-dynamically-to-an-exist
http://bv.doc.javake.cn/api/
//先销毁
$("#yourForm").data('bootstrapValidator').destroy();
$('#yourForm').data('bootstrapValidator', null);
//再重新初始化
$("#yourForm").bootstrapValidator({
message: '没有验证',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
message: '名字没有验证',
validators: {
notEmpty: {
message: '名字为必填项不能为空'
}
}
}
// add your_form_field here
}
}).on('success.form.bv', (e) {
// 阻止默认事件提交
e.preventDefault();
}););
参考资料:http://stackoverflow.com/questions/25639287/bootstrapvalidator-how-do-you-add-and-remove-validators-dynamically-to-an-exist
http://bv.doc.javake.cn/api/
相关文章推荐
- Boostrap模态窗口的学习小结
- Bootstrap 粘页脚效果
- Bootstrap学习1
- Bootstrap学习2
- 弹出框一 之 基于bootstrap和jquery的自定义弹出框
- Bootstrap 组件练习
- bootstrap 组件练习
- bootstrap 组件
- Bootstrap每天必学之级联下拉菜单
- bootstrap中按钮点击会自动刷新解决
- bootstrap modal 添加input Firefox报错
- bootstrap-datetimepicker时间插件使用
- bootstrap使用中的一些问题以及解决过程
- Bootstrap每天必学之级联下拉菜单
- Bootstrap Popover(弹出框)弹出自定义格式代码
- bootstrap模态框 使esc退出失效
- bootstrap使用心得总结
- bootstrap 简易模版
- Bootstrap 粘页脚,你必须得学会的简单技能
- Bootstrap 粘页脚