Form Field Errors From Form Validators using Zod validate all fields
Using this the
age
field will have an error as soon as an onChange
-Event has been fired from the username
field the age
field (in fact all fields) are validated and have an error.
Reproduction:
- Go to: https://stackblitz.com/edit/tanstack-form-a6vgcj?file=src%2Findex.tsx
- Type something into the username input2 Replies
other-emerald•12mo ago
That's the intended behavior. You can use
isTouched || isSubmitted
to only show touched fields if youd likeinland-turquoiseOP•12mo ago
Ah sure as I'm on the "Form" level here again the "Form" changed - not only the "Field" - makes sense.
Ended up with this:
state.meta.isTouched || form.state.isSubmitted
(state is from the FieldApi)