Design comparison
SolutionDesign
Solution retrospective
I have used useRef hook, therefore the components are uncontrolled. The validation works, however, the drawback is that on error (empty input field or incorrect email address submitted), the error icon and red highlight of the input field will disappear only after a new submit event (and of course when the errors are corrected).
From UX perspective, it is better if the validation happens on keystroke i.e. when you start typing into an empty cell, error icon and red border should disappear.
I guess I will be using onChange from now on...
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord