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)
Touched: not touched
Dirty: not dirty
isTouched and isDirty functions
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: