A field is dirty when its value differs from the initial one. It is touched after the user changes it or leaves it.
Call isDirty() or isTouched() for the whole form, or pass a path for one field. reset() clears both. resetDirty() makes the current values the initial ones, or the ones you pass, and resetTouched() clears only the touched state. isValid() tells if the form, or one field, passes the rules without showing any error, which suits a disabled submit button.
Type in the field, then clear it back to the first value.
When the handler you pass to onSubmit returns a promise, form.submitting is true until it settles.
Use it to disable the button and avoid a second submit.
The button waits for the handler to finish.
| Name | Description | Type |
|---|---|---|
| isDirty | a field, or any field, differs from the initial values | (path?: string) => boolean |
| isTouched | a field, or any field, was changed or left | (path?: string) => boolean |
| isValid | a field, or the whole form, passes the rules, with no error shown | (path?: string) => boolean |
| getTouched | the touched state of every field by path | () => Record<string, boolean> |
| setFieldTouched | mark a field as touched, or not | (path: string, touched?: boolean) => void |
| resetDirty | make the current values, or the given ones, the initial ones | (values?: Values) => void |
| setInitialValues | change the initial values without touching the current ones | (values: Values) => void |
| resetTouched | clear the touched state of every field | () => void |
| submitting | the handler of onSubmit is still running | boolean |