Replies: 1 comment 1 reply
-
Anyone know an uncomplicated solution? If it's not clear what the problem is, click on the link above then once the page is loaded do either of the following:
Is there a way to specify that fields focused with setFocus() default as untouched? Or is the only solution to have to imperatively write custom onBlur handlers that check if the field has been focused and if so manually trigger a validation only if the value doesn't match the default value? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have some uncontrolled forms that have client side validation using Zod schemas. There's also a useEffect to setFocus() on the first input when the form renders. It's all working fine, but if the user clicks anywhere outside the form or tries to navigate to a new page, etc. before they begin typing, it triggers the non empty error for the focused field. I would basically like the error to only be triggered only if the field is both dirty and has been touched by the "user" (not just by setFocus()).
I'm wondering if there is a simple solution within the API that avoids having to manually wire up custom onBlur handlers or having to resort to onSubmit mode. I did find a Github issue about this same problem, but it didn't have a solution and now I can't find it again for some reason.
For reference, here's an example schema:
Here's an example: https://npm-library-demo.vercel.app/login
Beta Was this translation helpful? Give feedback.
All reactions