bootstrap-validator
bootstrap-validator copied to clipboard
multiple error messages
Hello,
Lets say I have a field, that has a required and data-minlength="6" attributes.
I define error messages with data-error and data-minlength-error - and it works fine. But how can I make it so that one error takes precedence over other, so that both error messages are not displayed.
For example for a password field with required and data-minlength="6" when the user passes the input blank it will show both error messages like password field required
and password must be at least 6 chars
Is there a workaround for this?
Best regards, -C
I also think we should be able to show only one error each time.
+1 ul.list-unstyled li:not(:first-child) { display: none; }
+1 With js:
form.on('validate.bs.validator', function() {
$(this).find('div.help-block.with-errors').each(function() {
var err = $(this);
setTimeout(function() {
var ch = err.find('ul.list-unstyled').children('li');
for(var i = 1; i < ch.length; i++) {
ch[i].remove();
}
}, 0);
});
});