-
Hi! Please explain why reset() does not work if I give the button the name="reset". If you change the name to "reset1" everything works. Here's a sandbox: https://codesandbox.io/s/xenodochial-kapitsa-n6m5pj |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@Vlad991 : According to HTML specification, accessing form elements will follow this behavior:
While "react-hook-form" is using "field.closest('form').reset()" to clear all values in the form, in your example, it's matched with name attribute "reset" as a key of HTML form element therefore its method "reset" is overridden and return button element. Referrer: https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement#accessing_the_forms_elements |
Beta Was this translation helpful? Give feedback.
-
Some names will interfere with JavaScript access to the form's properties and elements. For example:
|
Beta Was this translation helpful? Give feedback.
@Vlad991 :
According to HTML specification, accessing form elements will follow this behavior:
While "react-hook-form" is using "field.closest('form').…