Skip to content

clearErrors

Clear form errors

clearErrors: (name?: string | string[]) => void

This function can manually clear errors in the form.

Props

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

  • string: reset the error on a single field or by key name.

  • string[]: reset errors on the given fields

Rules

  • This will not affect the validation rules attached to each inputs.

  • This method doesn't affect validation rules or isValid formState.

Examples

Thank you for your support

If you find React Hook Form to be useful in your project, please consider to star and support it.

Edit