1👍
It looks like library unfortunately is not resetting fields as per https://github.com/fergaldoyle/vue-form/issues/55
user there suggest you to use:
Object.keys(myFormState).forEach(k => {
if (k[0] == '$') return;
const field = myFormState[k];
field._setPristine();
field._setUntouched();
});
to set form as pristine and fields as untouched. Creator says he will add feature on next release.
You could also use vuelidate:
https://monterail.github.io/vuelidate/#sub-v-methods
which comes with a reset method. BTW in your tests don’t forget to rest model like dfsq says
0👍
Updated:
This is how you reset a form after successful submission.
- use javascript selectors to select the form. Assuming you only have
one form in the page, this would be ideal.
let form = document.querySelector('form');
form.reset();
- If you are using
vee-validate
, you need to reset the validator so that it cannot throw errors.
this.$validator.reset()
Thast should be all.
-5👍
custom validation display tag css name hide
$('.error').hide();
or other option
$('#formname').clearValidation();
Source:stackexchange.com