How to use custom validators of github.com/1000hz/bootstrap-validator

前端 未结 3 502
后悔当初
后悔当初 2020-12-19 02:53

From the documentation http://1000hz.github.io/bootstrap-validator/:

Add custom validators to be run. Validators should be functions that receive the

3条回答
  •  春和景丽
    2020-12-19 03:41

    You need to call your plugin manually, as custom options will not work with data-attributes:

    $().validator({
        custom: {
            'odd': function($el) { return Boolean($el.val() % 2);}
        }
    })
    

    then use it like this:

    
    

    Don't forget to add error messages, see code

提交回复
热议问题