We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
A medium frontend problem, graded against 5 test cases (2 of them hidden).
React and browser-platform problems - hooks, event handling, and rendering behaviour.
Reach for it when you see: A component, hook, or DOM-behaviour question rather than an algorithm.
More Frontend problems →Most candidates get the deciding right and forget half the reporting. The two things that separate a good answer:
1. Clear the valid state too. A field that was invalid on the last submit and is fixed now must lose `aria-invalid` and its message, or the form shows a stale error forever. Write both branches every time.
2. Match browser semantics. `minlength` does not apply to an empty optional field, and `required` is about the trimmed value. Copying the browser keeps your custom validation and the native `:invalid` pseudo-class in agreement.
`aria-invalid="true"` plus a message element that the input points at via `aria-describedby` is the accessible pattern; the message is what a screen reader announces when the field gets focus.
Time: O(inputs).
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
These apply to the pattern as a whole, not just this problem.