Bootstrap: invalid feedback stays hidden when use in a form group with a custom checkbox

Created on 27 Apr 2018  路  5Comments  路  Source: twbs/bootstrap

I have a custom checkbox which gets a validation error and the invalid-feedback div stays with display-none.

Below is the code generated. A message explaining why the checkbox must be checked is sometimes important.

<div class="form-group">
   <div class="custom-control custom-checkbox is-invalid" id="agree_terms_wrapper">
      <input class="custom-control-input is-invalid" type="checkbox" name="agree_terms" id="agree_terms" value="1">
      <label class="custom-control-label" for="agree_terms">I agree to the terms and conditions</label>
   </div>
   <div class="invalid-feedback">Terms and conditions must be carefully read and accepted. You cannot access our service otherwise.</div>
</div>

Most helpful comment

To fix this issue use class="invalid-feedback d-block"
it works perfect.

All 5 comments

Your invalid-feedback div needs to be inside the the custom-control div

<div class="form-group">
   <div class="custom-control custom-checkbox is-invalid" id="agree_terms_wrapper">
      <input class="custom-control-input is-invalid" type="checkbox" name="agree_terms" id="agree_terms" value="1">
      <label class="custom-control-label" for="agree_terms">I agree to the terms and conditions</label>
       <div class="invalid-feedback">Terms and conditions must be carefully read and accepted. You cannot access our service otherwise.</div>
   </div>
</div>

Whops. My bad :/ I had skipped that part of the docs. Thanks.

This Bootstrap 4 form validation error messages feature is insanely confusing and frustrating. I know so many people who have issues with it. It doesn't seem very intuitive. It was much simpler under BS3.

To fix this issue use class="invalid-feedback d-block"
it works perfect.

sorry if my comment a little bit late... just solved it by myself... u need to put form-control class in the input

Was this page helpful?
0 / 5 - 0 ratings