58
rated 0 times
[
64]
[
6]
/ answers: 1 / hits: 15405
/ 5 Years ago, mon, february 4, 2019, 12:00:00
Explanation
I'm trying to use Bootstrap's form validation with Select2's select boxes, but for some reason, it doesn't work properly. It does show this feedback text, but not the green/red border color, as you can see in the code below.
Codes
You can also see it in this JSFiddle.
$(.select).select2({
minimumResultsForSearch: Infinity
});
<link href=https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css rel=stylesheet />
<link href=https://rawgit.com/select2/select2/master/dist/css/select2.min.css rel=stylesheet />
<script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js></script>
<script src=https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js></script>
<script src=https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js></script>
<script src=https://rawgit.com/select2/select2/master/dist/js/select2.js></script>
<form class=was-validated>
<div class=form-group>
<select class=custom-select required>
<option value=>Open this select menu</option>
<option value=1>One</option>
<option value=2>Two</option>
<option value=3>Three</option>
</select>
<div class=invalid-feedback>Example invalid custom select feedback</div>
</div>
<div class=form-group>
<select class=select custom-select required>
<option value=>Open this select menu</option>
<option value=1>One</option>
<option value=2>Two</option>
<option value=3>Three</option>
</select>
<div class=invalid-feedback>Example invalid custom select feedback</div>
</div>
</form>
Thanks in advance,
Luiz.
More From » html