bootstrap-validator icon indicating copy to clipboard operation
bootstrap-validator copied to clipboard

multiple error messages

Open cambazz opened this issue 8 years ago • 3 comments

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

cambazz avatar Jan 20 '17 15:01 cambazz

I also think we should be able to show only one error each time.

dyegonery avatar May 01 '17 14:05 dyegonery

+1 ul.list-unstyled li:not(:first-child) { display: none; }

NexusMax avatar Jan 01 '18 14:01 NexusMax

+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);
    });
});

lestcape avatar Jul 26 '19 09:07 lestcape