Skip to content
On this page

clearErrors

This function can manually clear errors in the form.

Type

export type UseFormClearErrors = (
  name?: string | string[]
) => void

Props

TypeDescriptionExample
undefinedRemove all errors.clearErrors()
stringRemove single error.clearErrors("yourDetails.firstName")
string[]Remove multiple errors.clearErrors(["yourDetails.lastName"])

Usage

register('test.firstName', { required: true })
register('test.lastName', { required: true })
clearErrors('test') // will clear both errors from test.firstName and test.lastName
clearErrors('test.firstName') // for clear single input error

try it on playground