vue-form
vue-form copied to clipboard
Form field not validated until other field is typed in
I've a form field which has invalid data keyed in from backend. On opening the form I put the valid data into the field,but it keeps giving me the invalid error until i type into other field.
What is the solution to it.
What seems works is adding a ref to the html input and use
this.$ref.referenceToTheInput.dispatchEvent
to notify Vue about the changes:
dispatchEvent('input')
if the value was manipulated 'manually'
dispatchEvent('blur')
if the input was not touched before by the user (to trigger validation)
Using both will trigger the vue-form-validation.
Note: I am not sure how good the browser support of dispatchEvent
is and if this is considered a hack.
Don't forget to close the issue, if this solved your problem.