How (should) I use onBlur with onSubmit in React?

34 Views Asked by At

I have a form with multiple fields and want to avoid redoing validation/visual state updates on every keystroke (onChange). Don't want to delay validation until submit event either. onBlur seems appropriate middleground for this.

But what if a user clicks the submit button without interacting with the form at all? onBlur event would not be triggered, so validation/state updates would not occur. Does this mean I have to duplicate the validation/state update logic in my onBlurs and onSubmits? If so, how can I do this most optimally?

Technically, is it advisable to use onBlur with onSubmit?

0

There are 0 best solutions below