has-danger no longer working on Bootstrap v4 beta?

前端 未结 3 790
难免孤独
难免孤独 2020-12-10 03:44

According to the Bootstrap migration guide:

Renamed .has-error to .has-danger.

However, that doesn\'t seem to work. Border and t

相关标签:
3条回答
  • 2020-12-10 04:23

    Managed to get it to work. @ZimSystem is correct about this.

    .has-danger exist in Alpha version but it was removed in Bootstrap v4 Beta. You will need to use is-invalid selector in the input and also include class="invalid-feedback" for error message.

    Here is example:

    <div class="form-group has-danger">
        <label class="form-control-label">Username</label>
        <input type="text" class="form-control is-invalid">
        <div class="invalid-feedback">Sorry, that username's taken. Try another?</div>
    </div>
    
    0 讨论(0)
  • 2020-12-10 04:32

    Being that Bootstrap 4 is still in Beta, much of the migration documentation is not in sync with actual releases. Validation has changed in beta, and has-danger no longer exists.

    Also see: Can't make the validation work in Bootstrap 4

    0 讨论(0)
  • 2020-12-10 04:35

    It would appear that the beta version doesn't have the .has-* classes. As a work around, use the alpha-6 version

    https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css

    Updated fiddle with new CDN.

    https://jsfiddle.net/uLa0spfm/1/

    0 讨论(0)
提交回复
热议问题