bootstrap-validator
bootstrap-validator copied to clipboard
Can form validation work with bootstrap select ?
You can make custom validation if you want validate something in select list. if you want just validate select it self then add required to it.
Anyway custom validation is done so like that: add data-equals="foo" input/select
$('form').validator({
custom: {
equals: function($el) {
var matchValue = $el.data("equals") // foo
if ($el.val() !== matchValue) {
return "Hey, that's not valid! It's gotta be " + matchValue
}
}
}
});
See doc for more info: http://1000hz.github.io/bootstrap-validator/
Finally I realize the meaning.
I added a custom validator to the bootstrap select element
which looks like:
let select = $('<SELECT />', { 'data-live-search': true, 'id': item['property-name'], 'class': 'form-control selectpicker show-tick', 'data-validate': true, 'data-omnicolumn': 'exampre', 'data-omnicolumn-error': 'example-error' });
and it works fine.