关于这个答案,我的以下代码应该可以工作:
<form data-toggle="validator">
<div class="form-group has-feedback">
<label for="exampleInputText">Name</label>
<input type="text" class="form-control" id="exampleInputText" placeholder="text" data-odd>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<div class="help-block with-errors"></div>
</form>
<script type="text/javascript">
$('form').validator({
custom: {
'odd': function($el) { return false }
},
errors: {
'odd': 'error message'
}
})
</script>
但它不起作用 - 为什么?