A Bootstrap 6 signup form that shows every validation state at once: green valid fields, red invalid fields with specific hints, and an untouched neutral field. A gradient status panel beside the form lists each field with a check or cross icon and a progress bar counting how many are ready. Use it for sign-up, checkout or settings forms.
How it works
The <form class="fvs-form"> carries data-bs-validate="valid" and novalidate. That is Bootstrap 6's CSS-only validation: after the user edits a field, :user-valid and :user-invalid color it and reveal the sibling .valid-feedback or .invalid-feedback inside its .form-field. Native rules do the checking: required, type="email", minlength and pattern.
The script adds the class-based states that CSS alone cannot give. On load, fields that already have .is-valid or .is-invalid (as a server would render them) count as touched. Each change event marks a field as touched. From then on, every input event re-runs paint(), which toggles .is-valid/.is-invalid, sets aria-invalid and swaps the message. An empty field shows its data-fvs-missing text, and any other error shows the default .invalid-feedback text. data-fvs-match="fvs-pass" makes the confirmation field compare itself with the password through setCustomValidity().
updateStatus() gives each [data-fvs-for] item in .fvs-status a data-state of valid or invalid, and sets the --fvs-pct width of .fvs-progress-bar. On submit, every field is painted. If any fail, .fvs-alert lists their names and focus moves to the first one. If all pass, a spinner shows for a simulated request.
Customization
--fvs-accentand--fvs-accent-2on.fvs-root: set the gradient of the status panel, the link color and the submit button.--fvs-okand--fvs-badon.fvs-root: change the green and red of borders and feedback text.data-fvs-missingon any control: the message shown when the field is left empty.- Edit the text inside each
.invalid-feedbackto change the message for format errors such as a bad email or a short password. - Change
patternon#fvs-passor#fvs-slugto apply your own password or URL rules. - Remove the
.is-valid/.is-invalidclasses from the markup to start with a clean form. - Replace the
setTimeoutin thesubmithandler with afetch()call to your signup endpoint.
Use cases
- Sign-up forms: green valid and red invalid fields show specific hints for email, password and username
- Checkout pages: a progress bar and checklist show how many fields are ready before submitting
- Settings forms: the confirmation field compares itself with the password and flags a mismatch
- Design systems and docs: one page shows every validation state, from untouched to valid to invalid
Accessibility
Each control points to its feedback with aria-describedby, and the script keeps aria-invalid in sync. The summary box uses role="alert", so the list of failing fields is announced, and focus moves to the first invalid field. Status icons are decorative; the field names stay as text. The progress bar has role="progressbar" with a live aria-valuenow, and its animation turns off under prefers-reduced-motion.
Bootstrap 6 notes
Bootstrap 5's needs-validation plus a script that adds was-validated is gone. Bootstrap 6 uses data-bs-validate (add ="valid" for green states) and the :user-invalid pseudo-class. The mb-3 wrappers become .form-field. form-select is now form-control on a <select>, and form-check-input is .check. In 6.0.0-alpha.1, feedback placed after an .input-group is not shown, so style.css adds a small :has() rule for it. This is an alpha release, and its APIs can still change.