Snippets Registration

Bootstrap 5 Registration Form with Validation

A player registration form with floating labels, a country select, pill-style interest toggles and live client-side validation.

Bootstrap 5 No jQuery Jun 2019 2.2K views

<section class="wdw-stage">
  <div class="container" style="max-width:1000px">
    <div class="wdw-card overflow-hidden">
      <div class="row g-0">
        <div class="col-lg-5 wdw-aurora p-4 p-md-5 d-flex flex-column justify-content-between gap-4">
          <div>
            <span class="wdw-eyebrow text-white-50">Registration</span>
            <h2 class="wdw-heading h2 mt-1 mb-2 text-white">Join the league</h2>
            <p class="text-white-50 mb-4">Register as a player in under a minute. Step 1 of 1: your account and a few details.</p>
          </div>
          <ul class="list-unstyled mb-0 small">
            <li class="d-flex gap-2 align-items-start mb-2"><svg class="flex-shrink-0 mt-1" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg><span>Weekly fixtures and live standings</span></li>
            <li class="d-flex gap-2 align-items-start mb-2"><svg class="flex-shrink-0 mt-1" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg><span>Free kit for every registered player</span></li>
            <li class="d-flex gap-2 align-items-start mb-2"><svg class="flex-shrink-0 mt-1" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg><span>Find a team near you, any skill level</span></li>
          </ul>
        </div>
        <form class="col-lg-7 p-4 p-md-5" id="regForm" novalidate>
          <fieldset>
            <legend class="wdw-eyebrow mb-3">Account</legend>
            <div class="row g-3">
              <div class="col-12"><div class="form-floating"><input type="email" class="form-control" id="rgEmail" placeholder="Email address" aria-describedby="rgEmailFb" required autocomplete="email"><label for="rgEmail">Email address</label><div class="invalid-feedback" id="rgEmailFb">Enter a valid email address.</div></div></div>
              <div class="col-sm-6"><div class="input-group has-validation"><div class="form-floating"><input type="password" class="form-control" id="rgPass" placeholder="Password" minlength="8" autocomplete="new-password" aria-describedby="rgPassFb rgStrengthText" required><label for="rgPass">Password</label><div class="invalid-feedback" id="rgPassFb">Use at least 8 characters.</div></div><button type="button" class="btn btn-outline-secondary text-body" id="rgShow" aria-label="Show passwords" aria-pressed="false"><svg class="eye-on" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg><svg class="eye-off d-none" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.2 4M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7c1.7 0 3.2-.4 4.5-1M9.9 9.9a3 3 0 0 0 4.2 4.2"/></svg></button></div>
                <div class="progress mt-2" style="height:6px" aria-hidden="true"><div class="progress-bar" id="rgStrength" style="width:0"></div></div>
                <div class="form-text" id="rgStrengthText">Password strength: none</div></div>
              <div class="col-sm-6"><div class="form-floating"><input type="password" class="form-control" id="rgPass2" placeholder="Repeat password" aria-describedby="rgPass2Fb" required autocomplete="new-password"><label for="rgPass2">Repeat password</label><div class="invalid-feedback" id="rgPass2Fb">Passwords do not match.</div></div></div>
            </div>
          </fieldset>
          <fieldset class="mt-4">
            <legend class="wdw-eyebrow mb-3">About you</legend>
            <div class="row g-3">
              <div class="col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="rgFirst" placeholder="First name" aria-describedby="rgFirstFb" required autocomplete="given-name"><label for="rgFirst">First name</label><div class="invalid-feedback" id="rgFirstFb">Please enter your first name.</div></div></div>
              <div class="col-sm-6"><div class="form-floating"><input type="text" class="form-control" id="rgLast" placeholder="Last name" aria-describedby="rgLastFb" required autocomplete="family-name"><label for="rgLast">Last name</label><div class="invalid-feedback" id="rgLastFb">Please enter your last name.</div></div></div>
              <div class="col-sm-4"><div class="form-floating"><input type="number" class="form-control" id="rgAge" placeholder="Age" aria-describedby="rgAgeFb" required min="12" max="99"><label for="rgAge">Age</label><div class="invalid-feedback" id="rgAgeFb">Age must be 12 to 99.</div></div></div>
              <div class="col-sm-8"><div class="form-floating"><select class="form-select" id="rgCountry" aria-describedby="rgCountryFb" required><option value="" selected></option><option>United States</option><option>United Kingdom</option><option>Canada</option><option>Germany</option><option>Australia</option></select><label for="rgCountry">Country</label><div class="invalid-feedback" id="rgCountryFb">Select a country.</div></div></div>
              <div class="col-12"><div class="form-floating"><input type="text" class="form-control" id="rgAddress" placeholder="Address" aria-describedby="rgAddressFb" required autocomplete="street-address"><label for="rgAddress">Address</label><div class="invalid-feedback" id="rgAddressFb">Please enter your address.</div></div></div>
            </div>
          </fieldset>
          <fieldset class="mt-4">
            <legend class="fs-6 fw-semibold mb-2">Interests</legend>
            <div class="d-flex flex-wrap gap-2">
              <input type="checkbox" class="btn-check" id="rgTravel" autocomplete="off"><label class="btn btn-outline-primary rounded-pill" for="rgTravel"><svg class="pill-check" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>Travel</label><input type="checkbox" class="btn-check" id="rgReading" autocomplete="off"><label class="btn btn-outline-primary rounded-pill" for="rgReading"><svg class="pill-check" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>Reading</label><input type="checkbox" class="btn-check" id="rgSwim" autocomplete="off"><label class="btn btn-outline-primary rounded-pill" for="rgSwim"><svg class="pill-check" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>Swimming</label>
            </div>
          </fieldset>
          <div class="d-flex flex-column flex-sm-row gap-2 mt-4">
            <button type="submit" class="btn btn-primary rounded-pill flex-fill">Create account</button>
            <button type="reset" class="btn btn-link link-body-emphasis text-decoration-none rounded-pill px-4">Reset</button>
          </div>
          <div class="alert alert-success mt-3 mb-0 py-2" id="regOk" role="status" hidden>Thanks! Your registration was received.</div>
        </form>
      </div>
    </div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.

Free to use in personal and commercial projects under the MIT license.