원클릭으로
code-confirmation
Use when implementing verify codes with segmented input.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when implementing verify codes with segmented input.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | code-confirmation |
| description | Use when implementing verify codes with segmented input. |
| metadata | {"id":"code-confirmation","category":"forms","pattern":"Code Confirmation","source":"uxpatterns.dev","url":"https://uxpatterns.dev/patterns/forms/code-confirmation","sourcePath":"apps/web/content/patterns/forms/code-confirmation.mdx"} |
Verify codes with segmented input
A Code Confirmation (also called an OTP input or verification code input) is a specialized form component that allows users to enter short numeric or alphanumeric codes — typically 4–8 characters — sent via SMS, email, or authenticator app to verify identity. The defining characteristic is the segmented layout: each character occupies its own individual input box, providing a clear visual structure that guides users digit-by-digit and reduces transcription errors.
references/pattern.md, then choose the smallest viable variation.| Key | Action |
|---|---|
0–9 / A–Z | Enters a digit or character and advances focus to the next input |
Backspace | Clears current digit; if empty, moves focus to previous input |
Delete | Clears current digit without moving focus |
Arrow Left | Moves focus to the previous digit input |
Arrow Right | Moves focus to the next digit input |
Tab | Moves focus to the next focusable element outside the group |
Shift + Tab | Moves focus to the previous focusable element outside the group |
type="number" for Digit InputsThe Problem:
<input type="number"> accepts e, +, - and shows stepper arrows in some browsers. It also returns an empty string for checkValidity on certain non-numeric entries.
<!-- Bad -->
<input type="number" min="0" max="9" class="otp-digit" />
How to Fix It? Use type="text" with inputmode="numeric" and pattern="[0-9]".
<!-- Good -->
<input type="text" inputmode="numeric" pattern="[0-9]" maxlength="1" class="otp-digit" />
The Problem: Disabling paste breaks SMS autofill and forces users to type digit-by-digit from a copied code, causing significant frustration.
// Bad
input.addEventListener('paste', (e) => e.preventDefault());
How to Fix It? Handle paste to distribute characters across boxes.
// Good: distribute pasted text across all digit inputs
container.addEventListener('paste', (e) => {
e.preventDefault();
const text = e.clipboardData.getData('text').replace(/\D/g, '');
const digits = inputs; // NodeList of digit inputs
[...text].slice(0, digits.length).forEach((char, i) => {
digits[i].value = char;
});
// Move focus to the last filled digit or the next empty one
const lastFilled = Math.min(text.length, digits.length) - 1;
digits[lastFilled]?.focus();
});
The Problem:
Users who mistype a digit expect Backspace to clear it and return focus to the previous box. Without this, they're stranded on an empty box.
How to Fix It? Listen for keydown and navigate backward when the input is already empty.
input.addEventListener('keydown', (e) => {
if (e.key === 'Backspace' && input.value === '') {
const prev = getPreviousInput(input);
if (prev) {
prev.value = '';
prev.focus();
}
}
});
For full implementation detail, examples, and testing notes, see references/pattern.md.
Pattern page: https://uxpatterns.dev/patterns/forms/code-confirmation
Use when implementing help users understand their current location.
Use when implementing expand and collapse content sections.
Use when implementing user account configuration and preferences.
Use when implementing social activity and updates stream.
Use when implementing conversational AI chat interfaces.
Use when implementing handling AI-specific errors.