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
The great form validation feature allows showing feedback depending on the validation status of the form. Unfortunately, it restricts the feedback be only a direct sibling of the input.
It restricts using input-group feature together with the form validation, because the .input-group renders all elements in the group together, and .invaid-feedback in the same group makes it dirty, and doesn't work outside of the .input-group.
So, it is necessary to make .invalid-feedback (or .valid-feedback) available to be near to the input, but probably outside of the group where the input is actually present.
The best CSS filter is to have .invalid-feedback everywhere inside a .form-check which represents one "unit of check" on the form.
When any input elements in the .form-check group is invalid, the .invalid-feedback should be shown, but the .valid-feedback should be shown only when all elements inside a .form-check are valid.
I want to add feedbacks for the numeric input below the input group. It's impossible with the current Bootstrap config, but easy with the new CSS definitions:
<formclass="form needs-validation was-validated"
novalidateonsubmit="return false"
><divclass="row gx-1 gy-1"><divclass="form-check col col-12 col-sm-6 col-lg-4"><divclass="input-group"><inputtype="number"
class="form-control w-50"
placeholder="Input"
min="0"
step="0.001"
required/><selectclass="form-select input-group-text"
><optionvalue="1">Units</option><optionvalue="10">Tens</option><optionvalue="100">Hundreeds</option></select></div><divclass="invalid-feedback">Input decimal value ≥ 0.000</div><divclass="valid-feedback">Input OK</div><divclass="form-text">
Input some number
</div></div></div></form>
Prerequisites
Proposal
A simple CSS allows
.invalid-feedback
or.valid-feedback
be anywhere inside a.form-check
input div.Motivation and context
The great form validation feature allows showing feedback depending on the validation status of the form. Unfortunately, it restricts the feedback be only a direct sibling of the input.
It restricts using input-group feature together with the form validation, because the
.input-group
renders all elements in the group together, and.invaid-feedback
in the same group makes it dirty, and doesn't work outside of the.input-group
.So, it is necessary to make
.invalid-feedback
(or.valid-feedback
) available to be near to the input, but probably outside of the group where the input is actually present.The best CSS filter is to have
.invalid-feedback
everywhere inside a.form-check
which represents one "unit of check" on the form.When any input elements in the
.form-check
group is invalid, the.invalid-feedback
should be shown, but the.valid-feedback
should be shown only when all elements inside a.form-check
are valid.Let's the following HTML is used:
I want to add feedbacks for the numeric input below the input group. It's impossible with the current Bootstrap config, but easy with the new CSS definitions:
Working sample: https://codepen.io/nnseva/pen/xbKdeYG
The text was updated successfully, but these errors were encountered: