Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/4.0/components/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ We **highly recommend** custom validation styles as native browser defaults are

Here's how form validation works with Bootstrap:

- HTML form validation is applied via CSS's two pseudo-classes, `:invalid` and `:valid`. It applies to `<input>`, `<select>`, and `<textarea>` elements.
- HTML form validation is applied via CSS's two pseudo-classes, `:invalid` and `:valid`. It applies to `<input>`, `<select>`, and `<textarea>` elements with the `required` attribute.
- Bootstrap scopes the `:invalid` and `:valid` styles to parent `.was-validated` class, usually applied to the `<form>`. Otherwise, any required field without a value shows up as invalid on page load. This way, you may choose when to activate them (typically after form submission is attempted).
- As a fallback, `.is-invalid` and `.is-valid` classes may be used instead of the pseudo-classes for [server side validation](#server-side). They do not require a `.was-validated` parent class.
- Due to constraints in how CSS works, we cannot (at present) apply styles to a `<label>` that comes before a form control in the DOM without the help of custom JavaScript.
Expand Down
8 changes: 4 additions & 4 deletions scss/mixins/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
border-radius: .2rem;
}

.form-control,
.custom-select {
.form-control:required,
.custom-select:required {
.was-validated &:#{$state},
&.is-#{$state} {
border-color: $color;
Expand All @@ -70,7 +70,7 @@


// TODO: redo check markup lol crap
.form-check-input {
.form-check-input:required {
.was-validated &:#{$state},
&.is-#{$state} {
+ .form-check-label {
Expand All @@ -80,7 +80,7 @@
}

// custom radios and checks
.custom-control-input {
.custom-control-input:required {
.was-validated &:#{$state},
&.is-#{$state} {
~ .custom-control-indicator {
Expand Down