Is there a form reset and clear validation error function?

I have a form in popup.
If I open the popup after first time, I want show a completely new form so I should reset the form and clear previous validation error state.
Is there any method to achieve this?

BTW, I’m using React Component.

Haven’t tried it (and don’t use React) but have you tried a straight form reset?

I’m having the same problem.

Tried an , but the validation error text keeps visible after reset.

I reset my form with: this.$('#newAircraftForm')[0].reset(); referring to the form element. Works perfect for the values, all values are cleared. But the red validation texts remains visible. How to reset those as well?

I create a global function which use dom7 to reset form and clear error message

export function resetForm(form) {
  const $$ = Dom7;
  if (form && form.reset) {
    form.reset();
    const inputs = $$(form).find(".item-input-invalid");
    inputs.forEach((input) => $$(input).removeClass("item-input-invalid"));
  }
}

in your component:

import {resetForm} from '@/utils/utils';
...
resetForm(form);
....