Based on the documentation, it looks like you're supposed to be able to reset a form's validation by programmatically setting it's v-model value to null. This doesn't seem to work. Instead, resetting the HTML form (with something like document.getElementById("...").reset()) works just fine though.
data() {
return {
formValid: null,
validators: {
required: value => !!value || 'This field is required'
}
}
}
In this example, after failing the form validation and getting the error message to appear, setting formValid = null does not clear the validation, making the form pristine. Instead, I needed to reset that value and use document.getElementById("myForm").reset() to reset the form. I also tried running component.$forceUpdate() to see if it just wasn't dynamically updating, but that didn't help.
Based on the documentation, it looks like you're supposed to be able to reset a form's validation by programmatically setting it's
v-model
value tonull
. This doesn't seem to work. Instead, resetting the HTML form (with something likedocument.getElementById("...").reset()
) works just fine though.Example:
In this example, after failing the form validation and getting the error message to appear, setting
formValid = null
does not clear the validation, making the form pristine. Instead, I needed to reset that value and usedocument.getElementById("myForm").reset()
to reset the form. I also tried runningcomponent.$forceUpdate()
to see if it just wasn't dynamically updating, but that didn't help.