Form status
Get fields and form touched, dirty and submitting statuses
Docs
Package
Touched and dirty state
form.isTouched
and form.isDirty
fields provide information about current field status:
- Field is considered to be
touched
when user focused it or its value was changed programmatically withform.setFieldValue
handler - Field is considered to be
dirty
when its value was changed and new value is different from field value specified ininitialValues
(compared with fast-deep-equal)
isTouched and isDirty functions
touchTrigger option
touchTrigger
option allows customizing events that change touched state.
It accepts two options:
change
(default) – field will be considered touched when its value changes or it has been focusedfocus
– field will be considered touched only when it has been focused
Example of using focus
trigger:
Initial values
You can provide initial touched and dirty values with initialTouched
and initialDirty
properties.
Both properties support the same fields path format as errors:
resetTouched and resetDirty
form.resetTouched
and form.resetDirty
functions will make all fields clean and untouched.
Note that form.reset
will also reset touched
and dirty
state:
To reset values that are used for dirty check call form.resetDirty
with new values:
Submitting state
form.submitting
field will be set to true
if function passed to
form.onSubmit
returns a promise. After the promise is resolved or rejected,
form.submitting
will be set to false
:
You can also manually set form.submitting
to true
or false
: