Form status

Dirty and touched

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.

General

Type in the field, then clear it back to the first value.

Submitting

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.

Async submit

The button waits for the handler to finish.

APIs

Status

NameDescriptionType
isDirtya field, or any field, differs from the initial values(path?: string) => boolean
isToucheda field, or any field, was changed or left(path?: string) => boolean
isValida field, or the whole form, passes the rules, with no error shown(path?: string) => boolean
getTouchedthe touched state of every field by path() => Record<string, boolean>
setFieldTouchedmark a field as touched, or not(path: string, touched?: boolean) => void
resetDirtymake the current values, or the given ones, the initial ones(values?: Values) => void
setInitialValueschange the initial values without touching the current ones(values: Values) => void
resetTouchedclear the touched state of every field() => void
submittingthe handler of onSubmit is still runningboolean
Edit this page on GitHub