据我所知,jqBootstrapValidation应该自动验证html5元素,如下所示:
<input type="number" class="form-control" name="ordPrice" placeholder="Price" data-validation-number-message="Not a number">但事实并非如此。下面是我的js绑定:
$('#create_form').find('input,select,textarea').not('[†ype="submit"], [type="file"]').jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {
console.log('error!');
},
submitSuccess: function($form, event) {
console.log('success!');
event.preventDefault();
},
filter: function() {
return $(this).is(':visible');
}
});我是不是遗漏了什么非常基本的东西?
发布于 2013-09-30 16:48:09
尽管文档没有明确说明,但该插件仅适用于formatted for / with bootstrap表单。
要获得示例工作,您的输入至少应如下所示:
<div class="control-group">
<div class="controls">
<input type="number" class="form-control" name="ordPrice" placeholder="Price" data-validation-number-message="Not a number">
</div>
</div>如果没有control-group和controls,它将无法工作。推特的Bootstrap 3改变了from inputs的结构,control-group已经被form-group和其他许多变化所取代。出于这个原因,这个插件还不能与Twitter的Bootstrap 3一起使用。
另请参阅:http://getbootstrap.com/css/#forms-control-states (验证状态)。也许你应该试着让你的验证器使用它。
https://stackoverflow.com/questions/18793784
复制相似问题