A three-step signup form for Bootstrap 6 with a gradient progress bar, numbered step labels and validation that runs before each step can be left. It suits SaaS signups, trial requests and other long forms; the last screen confirms the account.
How it works
The root .msp-root carries a data-step attribute (1 to 4). CSS reads it to set the width of .msp-bar inside the Bootstrap 6 .progress element, so the first paint is already correct and the bar animates between 25%, 50%, 75% and 100%. The script keeps aria-valuenow, the .msp-count-step label and .msp-count-pct in sync, and moves aria-current="step" across the .msp-step list.
Each step is a <fieldset class="msp-panel"> with a data-msp-panel number; only the current one is visible. The Continue button is the form's submit button, so Enter also advances. On submit the script calls checkValidity() on every field of the current panel only. Invalid fields get .is-invalid and aria-invalid="true", the matching .invalid-feedback appears, and focus jumps to the first problem. Errors clear as soon as a field is fixed.
Step 1 uses the Bootstrap 6 Strength meter (data-bs-strength with four .strength-segment bars and a .strength-text label). Step 2 has a <select class="form-control"> and team-size radios built as .form-field-card tiles. Step 3 uses .switch toggles and a required .check for the terms. After the last step the button shows a .spinner-border while a timeout simulates the request, then the .msp-done panel receives focus. The .msp-restart button resets everything.
Customization
--msp-brandand--msp-brand-2on.msp-root: change the gradient of the progress bar and success icon;--msp-brandalso recolors buttons, radios, switches and focus rings through the overridden--bs-primary-*tokens.--msp-bg,--msp-lineand--msp-mutedon.msp-root: adjust the page tint, dividers and secondary text.TOTALinscript.jsplus the.msp-root[data-step]width rules instyle.css: add a fourth step by adding a panel, a.msp-stepitem and new widths.minlength="8"on#msp-password: change the password rule; update#msp-password-errorto match..msp-choicesgrid instyle.css: switch the team-size tiles from four columns to two or three.- Replace the
setTimeoutin the submit handler with afetch()POST ofnew FormData(form).
Use cases
- Account registration: three steps split the signup into small parts with a progress bar
- SaaS onboarding: each step is validated before the user can continue
- Secure sign-ups: a password strength meter helps users choose a good password
- Preference collection: radio cards and switches gather choices, then a success screen confirms
Accessibility
Every control has a visible label, and error messages are linked with aria-describedby. The step counter is an aria-live="polite" region, so screen readers hear "Step 2 of 3" when the step changes. The progress bar has role="progressbar" and an aria-label. Each step is a <fieldset> with a visually hidden <legend>. Focus moves to the first field of each new step and to the success message at the end. The bar animation respects prefers-reduced-motion.
Bootstrap 6 notes
Bootstrap 5's .form-check and .form-switch become a plain .check and a .switch wrapper inside .form-field. .form-select is gone, so selects use .form-control. btn-primary is now btn-solid theme-primary, and spinner-border-sm is spinner-sm. The Strength meter is new in Bootstrap 6 and needs no extra code. Built on Bootstrap 6.0.0-alpha.1, so APIs may still change.