question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors doesn't clear on change while using `onBlur` mode

See original GitHub issue

Describe the bug I’m not sure if this is a bug. But while using onBlur mode, errors don’t clear when a field is changed like they do while using onSubmit mode.

To Reproduce Here is a recreation.

Expected behavior I expect the errors to be cleared when the corresponding field changes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:20 (18 by maintainers)

github_iconTop GitHub Comments

8reactions
barrymaycommented, Aug 28, 2019

I think @Tymek 's right - if you have an error and you correct it (regardless of mode), the error should clear on the change, so you know it happened… I’d like to hear a scenario where that would be unwanted.

1reaction
bluebill1049commented, Sep 24, 2020

Hey @bluebill1049, thanks to you and everyone else for this awesome library.

I mentioned this on #283, but I figured it applied more here.

How can I 1) show an error onBlur, and 2) clear an error onChange?

I tried this:

useForm({ mode: 'onBlur', reValidateMode: 'onChange' })

This is great for showing an error on blur, but it also only clears the error on blur, not on change. Is there something wrong with that implementation?

Code sample here: https://codesandbox.io/s/react-hook-form-get-started-forked-vkk9j?file=/src/index.js:0-748

you want to use mode: onTouched, reVliadateMode is for after submit

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-hook-form: Validation not working when using onBlur ...
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >
useForm - register - Simple React forms validation
Performant, flexible and extensible forms with easy-to-use validation.
Read more >
react hook form onblur not working - You.com | The AI Search ...
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >
How to Use React-Hook-Form for Dead-Simple Forms - Medium
We can change this by passing useForm an object, where we can set the mode to when we want validation to be performed:...
Read more >
API Documentation - Simple React forms validation
onChange, string, Validation will trigger on the change event with each input, ... This option allows you to configure when inputs with errors...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found