You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I set reValidateMode to "onBlur", the validate function for all fields is triggered every time I blur any single field.
For example:
1. I enter a value in the “First Name” field, Email field, Last Name field and blur it.
2. The validate function for First Name, Last Name, and Email all get triggered when I will blur Email field, instead of just validating the field I blurred.
This behavior causes unnecessary validation calls for fields that haven’t even been interacted with yet, which is especially problematic when there are expensive operations like API calls inside validate (e.g., in lastName).
Expected Behavior
I would expect only the validation function of the field that was blurred to be triggered.
Question
• Is this the intended behavior of reValidateMode: "onBlur" in React Hook Form?
• If not, is there a way to limit validation to only the field that is being blurred?
• If this behavior is expected, what is the recommended approach to validate only one field at a time on blur, without triggering validations for other fields?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
When I set reValidateMode to "onBlur", the validate function for all fields is triggered every time I blur any single field.
For example:
1. I enter a value in the “First Name” field, Email field, Last Name field and blur it.
2. The validate function for First Name, Last Name, and Email all get triggered when I will blur Email field, instead of just validating the field I blurred.
This behavior causes unnecessary validation calls for fields that haven’t even been interacted with yet, which is especially problematic when there are expensive operations like API calls inside validate (e.g., in lastName).
Expected Behavior
I would expect only the validation function of the field that was blurred to be triggered.
Question
• Is this the intended behavior of reValidateMode: "onBlur" in React Hook Form?
• If not, is there a way to limit validation to only the field that is being blurred?
• If this behavior is expected, what is the recommended approach to validate only one field at a time on blur, without triggering validations for other fields?
See exemple here : https://codesandbox.io/p/sandbox/react-hook-form-v7-ts-template-4tn8i
Thanks for your help!
Nicolas
Beta Was this translation helpful? Give feedback.
All reactions