How to trigger onBlur when setValue? #8218
-
I have a situation where I want to "watch" user input on a field and if the input text is in a list, I will do something special (Display "name is in the list!" text above the form in codesandbox example"). Here is a example from sandbox. If user input, "aaaaa", "bbbbb" or "ccccc" in the name field, an special text is displayed. However with this approach, if the name list is big, comparing the value every time during user typing can be a big performance issue. I followed some advices in the discussion and changed to use onBlur to check against name list instead. Now this approach only check the user input on blur, and has great performance improvement. But now setValue("name", "aaaaa") no longer make the special text to display. How can I keep using onBlur while also trigger the onBlur function after I setValue for the field? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Trying checking the Here's an example CSB |
Beta Was this translation helpful? Give feedback.
-
I have an error and I don't know how I can solve it using the hook form, I would like my address fields to be self-completed when the address name is entered, these fields to validate first time in case I don't need to do any action in the field To be able to send this data, what can I do? |
Beta Was this translation helpful? Give feedback.
Trying checking the
"name"
value on getting the initial data against your listHere's an example CSB