StealThis .dev

Form — Branching wizard (conditional steps)

A multi-step account wizard whose path forks on the answers you give. Pick Personal and you get three lean steps; pick Business and the wizard inserts extra company and VAT/tax steps, recomputing its step sequence on the fly. The progress count, breadcrumb rail and Back button always reflect the real branch length, every step validates inline with aria-invalid messaging, a nested VAT field reveals conditionally, and the run ends on a summary tailored to the chosen path.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Branching wizard (conditional steps)

A signup wizard where the route adapts to the user instead of marching everyone through the same fixed funnel. The first step asks for an account type as two large radio cards. Choosing Personal keeps the journey to three steps — account type, profile, review — while Business splices in two extra steps for company information and tax/billing before the review. A single state object holds the collected answers and a computed step sequence; the moment the account type changes, the sequence is rebuilt, so the “Step 2 of 5” counter, the gradient progress track and the breadcrumb rail all reflect the genuine length of the active branch.

Each step validates on its own terms with real vanilla-JS logic: email and password rules on the profile step, required company name, team size and country selectors on the business step, and a VAT step whose VAT-number field is hidden until the user answers “Yes” to being VAT-registered — with a country-aware helper line nudging EU businesses. Errors render inline with aria-invalid, role="alert" messages and a polite aria-live status, and focus jumps to the first offending control. Back always returns to the correct prior step on the current branch, and editing the account type re-plans the remaining route without losing earlier answers.

The final step renders a summary <dl> assembled from state — personal accounts show only their fields, business accounts add grouped Company and Tax/billing sections — gated behind a terms checkbox. Submitting swaps in a tailored success panel (different copy for personal vs business), a toast helper confirms key actions, and Start over resets state cleanly. The layout is a centered card on the neutral product palette that collapses its two-column grids and segmented controls to a single column at 360px.

Illustrative UI only — fictional company, people, and tax data.