Skip to content
Knsept
Free playbook

One-time code input

Six boxes for a verification code. Auto-advance, backspace, arrow keys, paste, and SMS autofill all work.

JavaScriptUI Widgets Updated Oct 23, 2026
Live demo Reduced motion is on, so effects are toned down
<form class="otp-form" novalidate>
  <label class="otp-label" id="otp-label">Enter the 6-digit code</label>
  <div class="otp" role="group" aria-labelledby="otp-label">
    <input class="otp-box" inputmode="numeric" autocomplete="one-time-code" maxlength="6" aria-label="Digit 1">
    <input class="otp-box" inputmode="numeric" maxlength="1" aria-label="Digit 2">
    <input class="otp-box" inputmode="numeric" maxlength="1" aria-label="Digit 3">
    <input class="otp-box" inputmode="numeric" maxlength="1" aria-label="Digit 4">
    <input class="otp-box" inputmode="numeric" maxlength="1" aria-label="Digit 5">
    <input class="otp-box" inputmode="numeric" maxlength="1" aria-label="Digit 6">
  </div>
  <p class="otp-result" role="status">Try typing, or paste 123456.</p>
</form>

Each box holds one digit, but the input handler accepts several at once and spreads them forward. That single path covers typing, pasting, and SMS autofill: autocomplete="one-time-code" on the first box lets iOS and Android offer the code from a text message, and it lands as six digits in one box.

inputmode="numeric" brings up the number pad on phones without the quirks of type="number" (spinners, scroll-to-change, dropped leading zeros). Backspace on an empty box jumps back, and the arrow keys move between boxes, so it feels like one field.

Each box has its own label ("Digit 3"), and the group is labelled by the visible heading, so screen readers understand the structure.

More from the library

Forms & inputs live

Password strength meter

A live strength bar with a checklist of rules, plus a show/hide toggle. No library, no dark patterns.

Forms & inputs live

Range slider with value bubble

A styled native range input with a filled track and a bubble that follows the thumb. Same look in every browser.

Forms & inputs live

Toggle switch

An accessible on/off switch built on a real checkbox with role="switch". Keyboard, touch and screen readers work out of the box.