Six-box OTP input with auto-advance focus and validation

Design a component that allows the user to enter a 6-digit authentication code (OTP) typically sent via email or SMS. The component should render 6 separate input boxes, each accepting only a single digit (0-9). As the user types, focus should automatically advance to the next input, and backspace should move focus to the previous box. Validate that all 6 digits are filled before enabling the “Verify” button. Display a clear error message if the code is incomplete or contains any non-digit character. An OTP input in React should also set the inputmode attribute so mobile users get a numeric keyboard.
- User can type or paste "123456" and see each digit appear in a separate box.
- Typing "abc" or a special character is ignored.
- Pressing Enter with less than 6 digits shows an error.
The tests type and paste into your boxes and read the text on the screen, like a real user would. You don’t need test ids, specific class names, or an exact HTML structure. They only check that:
<form> does this for you).document.activeElement, so call .focus() on the next/previous box.