Bootstrap 5 Multi-Step Form with Progress Bar and Validation
A four-step project request form with selectable option cards, a progress bar, inline validation on required fields and a confirmation state.
<section class="wdw-stage">
<div class="container" style="max-width:820px">
<div class="wdw-card overflow-hidden" id="msForm">
<header class="d-flex flex-wrap justify-content-between align-items-center gap-3 p-4 border-bottom">
<div><span class="wdw-eyebrow">Project request</span><h2 class="h5 fw-bold text-body-emphasis mb-0 mt-1">Tell us a little more about your project</h2></div>
<a href="tel:1234567891" class="d-flex align-items-center gap-2 text-decoration-none fw-semibold text-body-emphasis"><span class="wdw-icon" style="width:2.5rem;height:2.5rem"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8.1 9.9a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2z"/></svg></span>123 456 7891</a>
</header>
<div class="px-4 pt-4">
<div class="d-flex justify-content-between small fw-semibold mb-2"><span class="wdw-muted" id="msStepLabel" aria-live="polite">Step 1 of 4</span><span class="text-primary" id="msPct">25% completed</span></div>
<div class="progress" role="progressbar" aria-label="Form progress" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" id="msProg" style="height:.5rem"><div class="progress-bar" id="msBar" style="width:25%"></div></div>
</div>
<form class="p-4 p-md-5" id="msSteps" novalidate>
<div class="ms-step" data-step="1">
<h3 class="h4 fw-bold text-body-emphasis mb-4" tabindex="-1">What should be done?</h3>
<div class="row g-3" role="radiogroup" aria-label="Project type">
<div class="col-12 col-sm-4"><input type="radio" class="btn-check" name="kind" id="kind-create" value="create" autocomplete="off" checked><label class="ms-choice w-100 h-100" for="kind-create"><span class="ms-tick" aria-hidden="true"></span><span class="wdw-icon ms-ic"><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4M10 8l-2 2 2 2M14 8l2 2-2 2"/></svg></span><span class="fw-bold text-body-emphasis">Create website</span><span class="small wdw-muted">Start from scratch</span></label></div>
<div class="col-12 col-sm-4"><input type="radio" class="btn-check" name="kind" id="kind-relaunch" value="relaunch" autocomplete="off"><label class="ms-choice w-100 h-100" for="kind-relaunch"><span class="ms-tick" aria-hidden="true"></span><span class="wdw-icon ms-ic"><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a9 9 0 1 1-3-6.7"/><path d="M21 4v5h-5"/></svg></span><span class="fw-bold text-body-emphasis">Website relaunch</span><span class="small wdw-muted">Refresh an existing site</span></label></div>
<div class="col-12 col-sm-4"><input type="radio" class="btn-check" name="kind" id="kind-unsure" value="unsure" autocomplete="off"><label class="ms-choice w-100 h-100" for="kind-unsure"><span class="ms-tick" aria-hidden="true"></span><span class="wdw-icon ms-ic"><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M9.1 9a3 3 0 0 1 5.8 1c0 2-3 2.5-3 4.5M12 17.5h.01"/></svg></span><span class="fw-bold text-body-emphasis">I don't know yet</span><span class="small wdw-muted">Help me decide</span></label></div>
</div>
</div>
<div class="ms-step d-none" data-step="2">
<h3 class="h4 fw-bold text-body-emphasis mb-1" tabindex="-1">Personal details</h3><p class="wdw-muted mb-4 small">All fields are required.</p>
<div class="row g-3">
<div class="col-12 col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="fname" placeholder="First name" required autocomplete="given-name" aria-describedby="fname-fb"><label for="fname">First name</label><div class="invalid-feedback" id="fname-fb">Please enter first name.</div></div></div>
<div class="col-12 col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="lname" placeholder="Last name" required autocomplete="family-name" aria-describedby="lname-fb"><label for="lname">Last name</label><div class="invalid-feedback" id="lname-fb">Please enter last name.</div></div></div>
<div class="col-12 col-sm-6"><div class="form-floating"><input type="email" class="form-control" id="email" placeholder="Email address" required autocomplete="email" aria-describedby="email-fb"><label for="email">Email address</label><div class="invalid-feedback" id="email-fb">Please enter email address.</div></div></div>
<div class="col-12 col-sm-6"><div class="form-floating"><input type="tel" class="form-control" id="mob" placeholder="Phone number" required autocomplete="tel" aria-describedby="mob-fb"><label for="mob">Phone number</label><div class="invalid-feedback" id="mob-fb">Please enter phone number.</div></div></div>
</div>
</div>
<div class="ms-step d-none" data-step="3">
<h3 class="h4 fw-bold text-body-emphasis mb-1" tabindex="-1">Website details</h3><p class="wdw-muted mb-4 small">Title and description are required.</p>
<div class="row g-3">
<div class="col-12 col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="cname" placeholder="Company name" aria-describedby="cname-fb" ><label for="cname">Company name (optional)</label><div class="invalid-feedback" id="cname-fb">Please enter company name.</div></div></div>
<div class="col-12 col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="zip" placeholder="Zip code" aria-describedby="zip-fb" ><label for="zip">Zip code (optional)</label><div class="invalid-feedback" id="zip-fb">Please enter zip code.</div></div></div>
<div class="col-12 col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="wtitle" placeholder="Website title" required aria-describedby="wtitle-fb" ><label for="wtitle">Website title</label><div class="invalid-feedback" id="wtitle-fb">Please enter website title.</div></div></div>
<div class="col-12 col-sm-6"><div class="form-floating"><select class="form-select" id="wtype"><option>E-commerce</option><option>Entertainment</option><option>Personal</option><option>Business</option><option>Portfolio</option><option>Education</option></select><label for="wtype">Website type</label></div></div>
<div class="col-12"><div class="form-floating"><textarea class="form-control" id="wdesc" aria-describedby="wdesc-fb" placeholder="Website description" style="height:110px;min-height:110px" required></textarea><label for="wdesc">Website description</label><div class="invalid-feedback" id="wdesc-fb">Please describe the website.</div></div></div>
</div>
</div>
<div class="ms-step d-none text-center py-4" data-step="4">
<div class="ms-done mx-auto mb-4"><svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg></div>
<h3 class="h4 fw-bold text-body-emphasis">Request submitted</h3>
<p class="wdw-muted mx-auto mb-4" style="max-width:26rem">Thanks. You will receive an estimate by email and phone within one business day.</p>
<button type="button" class="btn btn-outline-primary rounded-pill px-4" id="msReset">Start over</button>
</div>
<div class="d-flex justify-content-between gap-2 mt-5" id="msNav">
<button type="button" class="btn btn-outline-secondary rounded-pill px-4 invisible" id="msBack">Back</button>
<button type="button" class="btn btn-primary rounded-pill px-4" id="msNext">Next</button>
</div>
</form>
</div>
</div>
</section>
/* Web Designer Wall library style — shared base for every Bootstrap 5 snippet.
Indigo accent, Plus Jakarta Sans, soft cards, pill buttons. Works in light and dark. */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");
:root,
[data-bs-theme="light"] {
--wdw-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--bs-body-font-family: var(--wdw-font);
--bs-primary: #4f46e5;
--bs-primary-rgb: 79, 70, 229;
--bs-primary-text-emphasis: #3730a3;
--bs-primary-bg-subtle: #eef2ff;
--bs-primary-border-subtle: #c7d2fe;
--bs-link-color: #4f46e5;
--bs-link-color-rgb: 79, 70, 229;
--bs-link-hover-color: #4338ca;
--bs-link-hover-color-rgb: 67, 56, 202;
--bs-focus-ring-color: rgba(79, 70, 229, 0.25);
--bs-border-radius: 0.75rem;
--bs-border-radius-lg: 1rem;
--bs-border-radius-xl: 1.25rem;
--wdw-radius-card: 1.25rem;
--wdw-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px -16px rgba(16, 24, 40, 0.22);
--wdw-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px -4px rgba(16, 24, 40, 0.12);
--wdw-stage: #f5f6fb;
}
[data-bs-theme="dark"] {
--bs-primary: #818cf8;
--bs-primary-rgb: 129, 140, 248;
--bs-primary-text-emphasis: #c7d2fe;
--bs-primary-bg-subtle: rgba(129, 140, 248, 0.14);
--bs-primary-border-subtle: rgba(129, 140, 248, 0.35);
--bs-link-color: #a5b4fc;
--bs-link-color-rgb: 165, 180, 252;
--bs-link-hover-color: #c7d2fe;
--bs-link-hover-color-rgb: 199, 210, 254;
--bs-focus-ring-color: rgba(129, 140, 248, 0.35);
--wdw-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
--wdw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
--wdw-stage: #0f1117;
}
body { font-family: var(--wdw-font); -webkit-font-smoothing: antialiased; }
/* Bootstrap compiles its blue into these components; point them at the accent. */
.btn-primary {
--bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
--bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
--bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-bg: #a5b4fc; --bs-btn-hover-border-color: #a5b4fc; --bs-btn-hover-color: #0f1117; --bs-btn-active-color: #0f1117; }
.btn-outline-primary {
--bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary);
--bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary);
--bs-btn-active-bg: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
--bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}
.btn { --bs-btn-font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.btn-sm { min-height: 36px; }
.form-control, .form-select { min-height: 44px; border-radius: .75rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: rgba(var(--bs-primary-rgb), .6); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--bs-primary); border-color: var(--bs-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--bs-primary); }
.nav { --bs-nav-link-color: var(--bs-secondary-color); --bs-nav-link-hover-color: var(--bs-emphasis-color); }
.pagination { --bs-pagination-active-bg: var(--bs-primary); --bs-pagination-active-border-color: var(--bs-primary); --bs-pagination-color: var(--bs-body-color); --bs-pagination-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.progress, .progress-stacked { --bs-progress-bar-bg: var(--bs-primary); }
.list-group { --bs-list-group-active-bg: var(--bs-primary); --bs-list-group-active-border-color: var(--bs-primary); }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--bs-primary); border-radius: .875rem; box-shadow: var(--wdw-shadow-sm); }
.accordion { --bs-accordion-active-bg: var(--bs-primary-bg-subtle); --bs-accordion-active-color: var(--bs-primary-text-emphasis); --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.badge { font-weight: 600; }
/* Library building blocks — use these instead of re-inventing them per snippet. */
.wdw-stage { min-height: 100vh; display: flex; align-items: center; background: var(--wdw-stage); padding-block: 3rem; }
.wdw-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: var(--wdw-radius-card); box-shadow: var(--wdw-shadow); }
.wdw-card-sm { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color-translucent); border-radius: 1rem; box-shadow: var(--wdw-shadow-sm); }
.wdw-aurora { position: relative; color: #fff; background: radial-gradient(60% 55% at 100% 0, #818cf8 0, transparent 70%), radial-gradient(65% 60% at 0 100%, #ec4899 0, transparent 65%), #1e1b4b; }
.wdw-eyebrow { display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-primary); }
.wdw-heading { font-weight: 800; letter-spacing: -.02em; color: var(--bs-emphasis-color); }
.wdw-muted { color: var(--bs-secondary-color); }
.wdw-icon { width: 2.75rem; height: 2.75rem; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: .875rem; background: var(--bs-primary-bg-subtle); color: var(--bs-primary); }
/* Component */
.ms-choice { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 1.5rem 1rem; border: 1.5px solid var(--bs-border-color); border-radius: 1rem; background: var(--bs-body-bg); cursor: pointer; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.ms-choice:hover { border-color: var(--bs-primary-border-subtle); background: var(--bs-tertiary-bg); }
.ms-ic { width: 3.5rem; height: 3.5rem; border-radius: 1rem; margin-bottom: .5rem; }
.ms-tick { position: absolute; top: .75rem; right: .75rem; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 1.5px solid var(--bs-border-color); transition: all .15s; }
.btn-check:checked + .ms-choice { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.btn-check:checked + .ms-choice .ms-tick { background: var(--bs-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='m4 8.5 2.5 2.5L12 5.5'/%3E%3C/svg%3E") center/80% no-repeat; border-color: var(--bs-primary); }
.btn-check:focus-visible + .ms-choice { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.progress-bar { transition: width .35s ease; border-radius: 1rem; }
.ms-done { width: 4.5rem; height: 4.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.ms-step:not(.d-none) { animation: msIn .3s ease; }
@keyframes msIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ms-step:not(.d-none) { animation: none; } .progress-bar { transition: none; } }
.ms-step h3:focus { outline: none; }
.btn-check:checked + .ms-choice .ms-ic { background: var(--bs-body-bg); color: var(--bs-primary); }
#msBack { --bs-btn-color: var(--bs-body-color); --bs-btn-hover-color: var(--bs-body-color); --bs-btn-hover-bg: var(--bs-tertiary-bg); --bs-btn-active-color: var(--bs-body-color); --bs-btn-active-bg: var(--bs-secondary-bg); --bs-btn-border-color: var(--bs-border-color); --bs-btn-hover-border-color: var(--bs-border-color); --bs-btn-active-border-color: var(--bs-border-color); }
function initMultiStepForm() {
const form = document.getElementById('msSteps');
if (!form) return;
const steps = Array.from(form.querySelectorAll('.ms-step'));
const back = document.getElementById('msBack');
const next = document.getElementById('msNext');
const nav = document.getElementById('msNav');
const bar = document.getElementById('msBar');
const prog = document.getElementById('msProg');
const pct = document.getElementById('msPct');
const label = document.getElementById('msStepLabel');
const reset = document.getElementById('msReset');
let current = 0;
const validate = (step) => {
let ok = true;
step.querySelectorAll('[required]').forEach((field) => {
const valid = field.value.trim() !== '' && field.checkValidity();
field.classList.toggle('is-invalid', !valid);
field.classList.toggle('is-valid', valid);
field.setAttribute('aria-invalid', valid ? 'false' : 'true');
if (!valid) ok = false;
});
return ok;
};
const render = () => {
steps.forEach((s, i) => s.classList.toggle('d-none', i !== current));
const value = current === steps.length - 1 ? 100 : (current + 1) * 25;
bar.style.width = value + '%';
prog.setAttribute('aria-valuenow', value);
pct.textContent = value + '% completed';
label.textContent = 'Step ' + (current + 1) + ' of ' + steps.length;
back.classList.toggle('invisible', current === 0 || current === steps.length - 1);
nav.classList.toggle('d-none', current === steps.length - 1);
next.textContent = current === steps.length - 2 ? 'Submit request' : 'Next';
};
const focusHeading = () => {
const h = steps[current].querySelector('h3');
if (h) h.focus({ preventScroll: true });
};
next.addEventListener('click', () => {
if (!validate(steps[current])) return;
current = Math.min(current + 1, steps.length - 1);
render();
focusHeading();
});
back.addEventListener('click', () => { current = Math.max(current - 1, 0); render(); focusHeading(); });
form.addEventListener('input', (e) => {
if (e.target.matches('.is-invalid') && e.target.value.trim()) { e.target.classList.remove('is-invalid'); e.target.setAttribute('aria-invalid', 'false'); }
});
form.addEventListener('submit', (e) => e.preventDefault());
if (reset) reset.addEventListener('click', () => {
form.reset();
form.querySelectorAll('.is-valid, .is-invalid').forEach((f) => { f.classList.remove('is-valid', 'is-invalid'); f.removeAttribute('aria-invalid'); });
current = 0;
render();
focusHeading();
});
render();
}
initMultiStepForm();
Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.