About this set
A verification screen for a 6-digit code sent by email or SMS. Six single-digit boxes sit in a fieldset labelled Verification code, followed by one message line, a Verify button, a Resend link with a 30 second countdown and a link to use a different email. A small script makes the boxes behave like one field: typing moves to the next box, Backspace on an empty box goes back, the arrow keys move between boxes, and pasting the code into any box spreads it across all six. The first box has autocomplete=”one-time-code” and no length limit, so a code offered by the phone keyboard or browser is spread across the boxes too. Pressing Verify with empty boxes turns the message line into an error, marks the empty boxes aria-invalid and moves focus to the first gap; the message line is a polite live region linked to every box with aria-describedby. Resend clears the boxes and restarts the countdown. The boxes shrink to fit narrow phones. Nothing is verified: the script marks where to send the code to your server.
What’s included
- Auto-advance, Backspace to previous box and arrow key navigation
- Paste or one-time-code autofill spreads the code over all boxes
- Error message linked with aria-describedby and aria-invalid
- Resend button with a 30 second countdown that restarts
- Boxes shrink to fit 320px screens without overflow
Accessibility
The boxes are grouped in a fieldset with a visible legend, each box is named Digit 1 of 6 and so on, and they use inputmode="numeric". The message line is a polite live region described by every box, so errors are announced and read with the field. Boxes show an indigo border and ring on focus; buttons and links show a 2px outline. Transitions switch off under prefers-reduced-motion.
Customise it
Change --ot-brand, --ot-line and --ot-bad on .ot, and the number of boxes in the markup; the script counts them. In Tailwind edit the --color-ot-* theme colours and the h-[60px] max-w-[52px] box size.




















