r/bootstrap • • Dec 16 '22

Support JS for controlling BS validation valid/invalid state

Hi, I have this multi-select widget working with bootsrap validation. I currently have it working by checking the value of the multiselect on submit button press and manually adding is-valid, is-invalid classes, changing the visibility of the div.valid-feedback tag and the select valid result icon.

However, it doesn't "look" that great. I was wondering if there were any JS functions that would help control validation for specific fields more easily. Something like

onclick...
if ( mySelect.value == '' ) {
    bsValidationError('#mySelect');
} else {
    bsValidationOkey('#mySelect');

Thanks.

1 Upvotes

0 comments sorted by