TanStackT
TanStackโ€ข11mo agoโ€ข
11 replies
comprehensive-tomato

Relaunch validation even if there is already an error, and reset validation of certain fields

Hello,
I have a form with checkboxes and 2 date fields. Date fields are required only if the third checkbox is checked (this checkbox can be selected only if you choose the item 3 in the select).

The first problem is when I select the item 3 without value in the input at the right and validate the form there is an error, it's ok. But when I check the third checkbox, date fields are now required but if I submit, the error is not displayed because there is already an error on the input field. Is it possible to revalidate all the form on submit even if there is already an error ?

The second problem is when I filled the input and I unchecked the third checkbox, the date fields error is still here, I would like to remove it because dates are no longer required ? Is it possible ?

Here you can find the stackblitz with the demo projet https://stackblitz.com/edit/vitejs-vite-vya6grtl?file=src%2FApp.tsx

Hope someone can help me. Thanks ๐Ÿ™‚
StackBlitz
Next generation frontend tooling. It's fast!
Tanstack form validation - StackBlitz
Was this page helpful?