Why it often fails
Users must open messages, memorise digits and return, straining memory (Miller, 1956). Krol et al. (2015) showed two-factor authentication burdens and frustrates users. The goal is that users never manually transfer digits.
Autofill and paste
autocomplete="one-time-code" (MDN, n.d.-a) makes iOS suggest codes above the keyboard; Android Chrome supports the WebOTP API (MDN, n.d.-b) and apps the SMS Retriever (Google, n.d.). Use inputmode="numeric". Six split boxes look tidy but break paste and deletion; treat them as one input, a basic error prevention principle.
Resend, expiry and accessibility
Codes should expire quickly (NIST, 2024), so show remaining time and enable resend after a delay to prevent spamming. Keep input on errors and explain them. WCAG 2.2 (W3C, 2023) 2.2.1 requires ways to extend time, and 3.3.8 forbids blocking paste. Biometric login or passkeys can remove the step entirely.
FAQ
- Should I split the field into six boxes?
- It's easier to scan but tricky; if split visually, handle it as one input so paste and autofill work.
- What if the code never arrives?
- After the timer, offer resend, number check and alternatives like voice call or email.
Sources reviewed: 2026-10-27
References
- MDN Web Docs. (n.d.-a). HTML attribute: autocomplete. Mozilla. one-time-code autocomplete.
- MDN Web Docs. (n.d.-b). WebOTP API. Mozilla. Web SMS OTP retrieval.
- Google. (n.d.). SMS Retriever API overview. Google for Developers. Android SMS Retriever.
- Krol, K., Philippou, E., De Cristofaro, E., & Sasse, M. A. (2015). "They brought in the horrible key ring thing!" Analysing the usability of two-factor authentication in UK online banking. In Proceedings of the Workshop on Usable Security (USEC 2015). Internet Society. Burden of two-factor authentication.
- National Institute of Standards and Technology. (2024). Digital identity guidelines: Authentication and authenticator management (NIST SP 800-63B-4). OTP validity and SMS limits.
- Miller, G. A. (1956). The magical number seven, plus or minus two: Some limits on our capacity for processing information. Psychological Review, 63(2), 81–97. Memorising six digits across apps.
- World Wide Web Consortium. (2023). Web Content Accessibility Guidelines (WCAG) 2.2. Criteria 2.2.1 and 3.3.8.
