Snippets Email

Bootstrap 5 Email Verification Code Form (OTP Input)

An email verification screen with six single-digit code boxes that auto-advance, support paste and backspace navigation, and validate on submit. A resend link is disabled behind a short countdown.

Bootstrap 5 No jQuery Dec 2019 3.4K views

<section class="wdw-stage">
  <div class="container" style="max-width: 600px">
    <form class="wdw-card p-4 p-md-5 text-center" id="otpForm" novalidate>
      <div class="text-start mb-3">
        <a href="#" class="small fw-semibold text-decoration-none d-inline-flex align-items-center gap-1">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6"/></svg>
          Change email
        </a>
      </div>
      <span class="wdw-icon mx-auto mb-3" style="width:3.5rem;height:3.5rem;border-radius:1.1rem">
        <svg width="26" height="26" 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="5" width="18" height="14" rx="3"/><path d="M3.5 7l8.5 6 8.5-6"/></svg>
      </span>
      <h1 class="h3 wdw-heading mb-2">Verify your email</h1>
      <p class="wdw-muted mb-4">We sent a 6-digit code to <strong class="text-body-emphasis">[email protected]</strong>. Enter it below to finish signing up.</p>

      <fieldset class="mb-2">
        <legend class="visually-hidden">Verification code</legend>
        <div class="d-flex justify-content-center gap-2 gap-sm-3 otp-row" id="otpRow">
          <input class="form-control otp-box is-filled" inputmode="numeric" maxlength="1" autocomplete="one-time-code" aria-label="Digit 1" value="4">
          <input class="form-control otp-box is-filled" inputmode="numeric" maxlength="1" aria-label="Digit 2" value="8">
          <input class="form-control otp-box is-filled" inputmode="numeric" maxlength="1" aria-label="Digit 3" value="2">
          <input class="form-control otp-box is-filled" inputmode="numeric" maxlength="1" aria-label="Digit 4" value="9">
          <input class="form-control otp-box is-next" inputmode="numeric" maxlength="1" aria-label="Digit 5">
          <input class="form-control otp-box" inputmode="numeric" maxlength="1" aria-label="Digit 6">
        </div>
      </fieldset>
      <p class="small mb-3 text-danger-emphasis" id="otpMsg" role="status" aria-live="polite" style="min-height:1.25rem"></p>

      <button type="submit" class="btn btn-primary rounded-pill w-100" id="otpSubmit">Verify email</button>
      <p class="small wdw-muted mt-4 mb-0">
        <span id="otpTimer">Resend code in 0:30</span>
        <button type="button" class="btn btn-link p-0 align-baseline small fw-semibold text-decoration-none" id="otpResend" hidden style="min-height:0">Resend code</button>
      </p>
    </form>
  </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.