One-time codes
A code arrives in another app and expires quickly, and copying it across by hand invites mistakes.
The answer
Use one field that can be pasted into and filled automatically, and do not submit by itself. As strong as the weakest rule behind it: moderate.
-
Allow the code to be pasted and filled in automatically.
WCAG 2.2 level AA (3.3.8). Reopened and checked.
- Applies when
- Always.
- Based on
- Standard or law
- Principle
- Work for everyone
- StandardStandard: Understanding SC 3.3.8: Accessible Authentication (Minimum)W3C WAI, 2023
-
Don’t submit when the last digit is typed, unless you said you would.
WCAG 2.2 level A (3.2.2): submitting on input without prior notice is a listed failure. Reopened and checked in the pilot. One component library offers automatic submit as an option.
- Applies when
- Always.
- Based on
- Standard or law
- Principle
- Keep people in control
- StandardStandard: Understanding SC 3.2.2 On Input (Level A)W3C WAI
- GuidanceGuidance: One-Time Password Field (Radix Primitives)Radix UI
-
Use one field for the code, marked with the one-time-code token, with a number pad for numeric codes.
GOV.UK, Google, Twilio and MDN agree. No test of one field against one box per digit was found. Rated 3.
- Applies when
- Always.
- Based on
- Convention
- Principle
- Let practiced people go faster
- GuidanceGuidance: Confirm a phone number (GOV.UK Design System pattern)GOV.UK Design System
- Guidance: SMS OTP form best practicesweb.dev, 2020
- Guidance: Best Practices for OTP Input Forms in HTMLAlvin Lee, 2025
- Guidance: Simple One-Time Passcode InputsTyler Sticka, 2025
- Guidance: HTML attribute: autocompleteMDN Web Docs
The other rules
-
Don’t use one box per digit.
WCAG's guidance flags split boxes where a paste fills only the first; a major component library ships a per-digit field. Convention with dissent, so 2.
- Applies when
- Always.
- Based on
- Convention
- Principle
- Prevent errors
- Common mistake
- One box per digit that breaks paste (rule 4).
- StandardStandard: Understanding SC 3.3.8: Accessible Authentication (Minimum)W3C WAI, 2023
- GuidanceGuidance: Simple One-Time Passcode InputsTyler Sticka, 2025
- Guidance: Best Practices for OTP Input Forms in HTMLAlvin Lee, 2025
- Guidance: One-Time Password Field (Radix Primitives)Radix UI
-
Accept the code with spaces or hyphens.
GOV.UK only; reopened and checked. Rated 2.
- Applies when
- Always.
- Based on
- Convention
- Principle
- Prevent errors
- GuidanceGuidance: Confirm a phone number (GOV.UK Design System pattern)GOV.UK Design System
-
Say how long the code lasts, say when it has expired, and offer a new one.
GOV.UK guidance, and a 72-person study in which typed codes took 15 to 17 seconds and 30-second codes caused trouble. Rated 2.
- Applies when
- Always.
- Based on
- Practitioner research
- Principle
- Keep people informed
- Common mistake
- A code that expires with no message and no way to get another (rule 6).
- ExperimentExperiment: A Usability Study of Five Two-Factor Authentication MethodsReese, 2019
- GuidanceGuidance: Confirm a phone number (GOV.UK Design System pattern)GOV.UK Design System
-
Format the text message so the phone can offer the code on the right site.
Vendor guidance; one security paper argues one-tap filling can help phishing. Rated 2.
- Applies when
- The code is sent by text message.
- Based on
- Convention
- Principle
- Let practiced people go faster
- User researchUser research: Taken Out of Context: Security Risks with Security Code AutoFill in iOS & macOSGutmann and Murdoch, 2019
- GuidanceGuidance: SMS OTP form best practicesweb.dev, 2020
- Guidance: Verify phone numbers on the web with the WebOTP APIGoogle Chrome developers, 2019
Accessibility
Open questions
- OpenNo controlled test of one field against split boxes, of automatic submit, or of resend and expiry wording was found.
- OpenHow long a code should stay valid: GOV.UK uses 15 minutes; no evidence.
Sources
- ExperimentExperiment: A Usability Study of Five Two-Factor Authentication MethodsReese, 2019
- User researchUser research: Taken Out of Context: Security Risks with Security Code AutoFill in iOS & macOSGutmann and Murdoch, 2019
- StandardsStandard: Understanding SC 3.3.8: Accessible Authentication (Minimum)W3C WAI, 2023
- Standard: Understanding SC 3.2.2 On Input (Level A)W3C WAI
- GuidanceGuidance: One-Time Password Field (Radix Primitives)Radix UI
- Guidance: Confirm a phone number (GOV.UK Design System pattern)GOV.UK Design System
- Guidance: SMS OTP form best practicesweb.dev, 2020
- Guidance: Best Practices for OTP Input Forms in HTMLAlvin Lee, 2025
- Guidance: Simple One-Time Passcode InputsTyler Sticka, 2025
- Guidance: HTML attribute: autocompleteMDN Web Docs
- Guidance: Verify phone numbers on the web with the WebOTP APIGoogle Chrome developers, 2019
Related
- Autofill and identifying input purposeMark each field with what it is for, and never block autofill, pasting or password managers.Answer: settled.
- Log inNever block paste or password managers, and slow repeated attempts instead of locking people out.Answer: weak.
- Time limitsAvoid time limits. Where one is needed, warn before it ends and let people extend it.Answer: moderate.