You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Give some guidance on when someone might use any of the three
validation states. Fixes#18702.
- Improve the examples to provide examples of supporting validation
text with the new `.form-control-feedback`, as well as always-present
help text. Nullifies #18704.
Copy file name to clipboardExpand all lines: docs/components/forms.md
+17-2Lines changed: 17 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -660,15 +660,22 @@ Block help text—for below inputs or for longer lines of help text—can be eas
660
660
661
661
## Validation
662
662
663
-
Bootstrap includes validation styles for danger, warning, and success states on form controls.
663
+
Bootstrap includes validation styles for danger, warning, and success states on form controls. Here's a rundown of how they work:
664
664
665
-
- To use, add `.has-warning`, `.has-danger`, or `.has-success` to the parent element. Any `.form-control-label`, `.form-control`, and `.text-help` within that element will receive the validation styles.
666
665
- To use, add `.has-warning`, `.has-danger`, or `.has-success` to the parent element. Any `.form-control-label`, `.form-control`, or custom form element will receive the validation styles.
667
666
- Contextual validation text, in addition to your usual form field help text, can be added with the use of `.form-control-feedback`. This text will adapt to the parent `.has-*` class. By default it only includes a bit of `margin` for spacing and a modified `color` for each state.
668
667
- Validation icons are `url()`s configured via Sass variables that are applied to `background-image` declarations for each state.
669
668
- You may use your own base64 PNGs or SVGs by updating the Sass variables and recompiling.
670
669
- Icons can also be disabled entirely by setting the variables to `none` or commenting out the source Sass.
671
670
671
+
Generally speaking, you'll want to use a particular state for specific types of feedback:
672
+
673
+
-**Danger** is great for when there's a blocking or required field. A user *must* fill in this field properly to submit the form.
674
+
-**Warning** works well for input values that are in progress, like password strength, or soft validation before a user attempts to submit a form.
675
+
- And lastly, **success** is ideal for situations when you have per-field validation throughout a form and want to encourage a user through the rest of the fields.
676
+
677
+
Here are some examples of the aforementioned classes in action.
678
+
672
679
{% comment %}
673
680
{% callout warning %}
674
681
#### Conveying validation state to assistive technologies and colorblind users
@@ -683,16 +690,24 @@ Ensure that an alternative indication of state is also provided. For instance, y
683
690
<divclass="form-group has-success">
684
691
<labelclass="form-control-label"for="inputSuccess1">Input with success</label>
0 commit comments