Selectpicker doesn't work with parsley
sanoj26692 opened this issue · comments
i want to validate bootstrap-select (selectpicker), i done everything that's need it works fine with input
but in select
it just display error message and not the border color for select
here is the code https://jsfiddle.net/sanoj908572/jdo6reaf/2/
Even though this issue has already been closed, here is my solution:
<div class="form-group">
<label for="example">Select:</label>
<select multiple class="form-control selectpicker" id="example" name="example"
data-parsley-errors-container="#error-container" required="">
<option value="1">Option 1</option>
<option value="1">Option 2</option>
</select>
<div id="error-container"></div>
</div>
$('#modifyExistingModal form').parsley({triggerAfterFailure: 'focusout changed.bs.select'}).on('field:validated', function() {
var ok = $('.parsley-error').length === 0;
// do something with ok
})
.on('form:submit', function() {
return false; // Don't submit form for this demo
});
The important parts are:
data-parsley-errors-container="#selector"
andparsley({triggerAfterFailure: 'focusout changed.bs.select'})
.
See also events of bootstrap-select and this stackoverflow answer. jsfiddle of another solution.