Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Compatibility with selectpicker? #115

Closed
nextpulse opened this issue Apr 16, 2015 · 3 comments
Closed

Compatibility with selectpicker? #115

nextpulse opened this issue Apr 16, 2015 · 3 comments

Comments

@nextpulse
Copy link

Anyone have any tips or know if this is compatible with bootstrap selectpicker?

@xplicit
Copy link

xplicit commented Jun 16, 2015

I have run into issue that selectpicker (https://github.com/silviomoreto/bootstrap-select) is not validated with bootstrap-validator. The cause of this behaviour is that selectpicker makes the underlying <select> element hidden when bootstrap-validator validates only visible fields

var inputSelector = ':input:not([type="submit"], button):enabled:visible'

If remove :visible part from selector bootstrap-validator starts to validate selectpicker, but this is bad solution. Any ideas how this issue could be resolved are appreciated.

@xward1
Copy link

xward1 commented Dec 15, 2015

I had the same issue using bootstrap-select (selectpicker). I solved it by doing this:

$('.selectpicker').on('change', function() {
    var m, h, x, $el = $(this);
    var fg = $el.parents('div.form-group');
    if ($el[0].hasAttribute('required') || $el.is('[required]')) {
      if ($el[0].checkValidity() === false) {
        m = $el.data('error');
        h = '<ul class="list-unstyled"><li>' + m + '</li></ul>';
        fg.addClass('has-errors').find('div.help-block').html(h);
        //console.log(m);
      }
      else {
        fg.removeClass('has-errors').find('div.help-block').html('');
      }
    }
  });

@maximelebreton
Copy link

+1

1000hz added a commit that referenced this issue Jul 15, 2016
If you want this behavior back, add
`$.fn.validator.Constructor.INPUT_SELECTOR += ':enabled:visible'`
to your code. (refs #115) (refs #134) (refs #317)
@1000hz 1000hz closed this as completed Jul 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants