Search code examples
typescriptreact-hook-formreact-typescript

react-hook-form revalidating doesn't start


Found code example at

Forked a sandbox(original is buggy and contains errors)

I want to use custom validation callbacks at each form input element, so I did provide options in register, but validate is triggered only at submition even useForm is configured with

{ reValidateMode: "onChange" }

The question is how to start validate on onChange event in that case described in sandbox


Solution

  • but validate is triggered only at submition even useForm is configured with

    Thats because reValidateMode is triggered only after form submission. To validate before the form is submitted, you should use mode property for onChange, onBlur etc events.

    Read more