How can I validate the validate the form depending on if the specific values are chosen from Select dropdown in React hook form? #3220
Unanswered
lakhandeshpande
asked this question in
General
Replies: 1 comment 6 replies
-
|
Beta Was this translation helpful? Give feedback.
6 replies
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.
-
I have a select field as follows
<Select type="select" label={label} ref={ !checkvalidation ? register({ required: 'Please select at least one workday option' }) : register({ required: false }) } watch={watch} name={name} size="sm" defaultValue="" onChange={validateWorkPattern(watch, employmentId)} >
On value change I am checking if specific value selected else should be return false for setting required to true.
But the validateWorkPattern function is taking long and slowing down the performance.
How can I achieve this without impacting performance.
I would also like to know if I could do it onSubmit but how to execute the onsubmit?
Beta Was this translation helpful? Give feedback.
All reactions