.was-validated
<form class="was-validated mb-3"> <select class="form-select" id="valid-was-validated-single-field" data-placeholder="Choose one thing"> <option></option> <option>Reactive</option> <option>Solution</option> <option>Conglomeration</option> <option>Algoritm</option> <option>Holistic</option> </select> </form> <form class="was-validated mb-3"> <select class="form-select" data-placeholder="Choose anything" id="valid-was-validated-multiple-field" multiple> <option>Christmas Island</option> <option>South Sudan</option> <option>Jamaica</option> <option>Kenya</option> <option>French Guiana</option> <option>Mayotta</option> <option>Liechtenstein</option> <option>Denmark</option> <option>Eritrea</option> <option>Gibraltar</option> <option>Saint Helena, Ascension and Tristan da Cunha</option> <option>Haiti</option> <option>Namibia</option> <option>South Georgia and the South Sandwich Islands</option> <option>Vietnam</option> <option>Yemen</option> <option>Philippines</option> <option>Benin</option> <option>Czech Republic</option> <option>Russia</option> </select> </form>
$( '#valid-was-validated-single-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), } ); $( '#valid-was-validated-multiple-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), closeOnSelect: false, } );
.is-valid
<div class="mb-3"> <select class="form-select is-valid" id="valid-is-valid-single-field" data-placeholder="Choose one thing"> <option></option> <option>Reactive</option> <option>Solution</option> <option>Conglomeration</option> <option>Algoritm</option> <option>Holistic</option> </select> </div> <div class="mb-3"> <select class="form-select is-valid" data-placeholder="Choose anything" id="valid-is-valid-multiple-field" multiple> <option>Christmas Island</option> <option>South Sudan</option> <option>Jamaica</option> <option>Kenya</option> <option>French Guiana</option> <option>Mayotta</option> <option>Liechtenstein</option> <option>Denmark</option> <option>Eritrea</option> <option>Gibraltar</option> <option>Saint Helena, Ascension and Tristan da Cunha</option> <option>Haiti</option> <option>Namibia</option> <option>South Georgia and the South Sandwich Islands</option> <option>Vietnam</option> <option>Yemen</option> <option>Philippines</option> <option>Benin</option> <option>Czech Republic</option> <option>Russia</option> </select> </div>
$( '#valid-is-valid-single-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), } ); $( '#valid-is-valid-multiple-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), closeOnSelect: false, } );
<form class="was-validated mb-3"> <select class="form-select" id="invalid-was-validated-single-field" data-placeholder="Choose one thing" required> <option></option> <option>Reactive</option> <option>Solution</option> <option>Conglomeration</option> <option>Algoritm</option> <option>Holistic</option> </select> </form> <form class="was-validated mb-3"> <select class="form-select" data-placeholder="Choose anything" id="invalid-was-validated-multiple-field" multiple required> <option>Christmas Island</option> <option>South Sudan</option> <option>Jamaica</option> <option>Kenya</option> <option>French Guiana</option> <option>Mayotta</option> <option>Liechtenstein</option> <option>Denmark</option> <option>Eritrea</option> <option>Gibraltar</option> <option>Saint Helena, Ascension and Tristan da Cunha</option> <option>Haiti</option> <option>Namibia</option> <option>South Georgia and the South Sandwich Islands</option> <option>Vietnam</option> <option>Yemen</option> <option>Philippines</option> <option>Benin</option> <option>Czech Republic</option> <option>Russia</option> </select> </form>
$( '#invalid-was-validated-single-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), } ); $( '#invalid-was-validated-multiple-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), closeOnSelect: false, } );
.is-invalid
<div class="mb-3"> <select class="form-select is-invalid" id="invalid-is-invalid-single-field" data-placeholder="Choose one thing"> <option></option> <option>Reactive</option> <option>Solution</option> <option>Conglomeration</option> <option>Algoritm</option> <option>Holistic</option> </select> </div> <div class="mb-3"> <select class="form-select is-invalid" data-placeholder="Choose anything" id="invalid-is-invalid-multiple-field" multiple> <option>Christmas Island</option> <option>South Sudan</option> <option>Jamaica</option> <option>Kenya</option> <option>French Guiana</option> <option>Mayotta</option> <option>Liechtenstein</option> <option>Denmark</option> <option>Eritrea</option> <option>Gibraltar</option> <option>Saint Helena, Ascension and Tristan da Cunha</option> <option>Haiti</option> <option>Namibia</option> <option>South Georgia and the South Sandwich Islands</option> <option>Vietnam</option> <option>Yemen</option> <option>Philippines</option> <option>Benin</option> <option>Czech Republic</option> <option>Russia</option> </select> </div>
$( '#invalid-is-invalid-single-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), } ); $( '#invalid-is-invalid-multiple-field' ).select2( { theme: "bootstrap-5", width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style', placeholder: $( this ).data( 'placeholder' ), closeOnSelect: false, } );