TanStackT
TanStack2y ago
49 replies
nursing-lime

Trigger onChange only on dirty fields

Is it possible to only trigger the onChange validation after the field is dirty ?

I want the validation to first occur when the user leaves the field (onBlur). Then when the user comes back to the field (now dirty), I want the validation to occur onChange. Is it possible to do this ?

In RHF, i would do this with the onTouched event - https://www.react-hook-form.com/api/useform/#mode
onTouch in RHF - Validation is initially triggered on the first blur event. After that, it is triggered on every change event.
Performant, flexible and extensible forms with easy-to-use validation.
Was this page helpful?