Display a form with certain validation rules.
Good practice is to disable the submit button, so the user can not submit the form before all is good.
Another good practice is to not show all errors from the start, but allow the user to fill out the form first before displaying errors (using data-vv-delay is even better).
Create a form including an input field with a "required" validation rule.
Unclear how to implement a submit button that is disabled until the input is filled in.
You can use the flags to implement this:
http://vee-validate.logaretm.com/examples.html#flags-example
You could use the validated and valid flags combination to produce the desired result.
Thanks for the pointer!
Does anyone have an example? New to Vue and VeeValidate, and finding a working example of this is proving difficult.
Doh. Spend ages searching, so ask a question, then find the answer almost immediatel after.
computed: {
formValidated() {
return Object.keys(this.fields).some(key => this.fields[key].validated) && Object.keys(this.fields).some(key => this.fields[key].valid);
}
}
@logaretm , the link you shared above with #flags-example is 404'ed.
@pkbarbiedoll yea, the docs were updated a month ago:
You can make a
isFormInvalid: function () {
return this.errors.count() > 0 || !(Object.keys(this.fields).some(key => this.fields[key].dirty));
}
Method
and then
<button :class="['btn btn-primary btn-block',(isFormInvalid == true ? 'disabled' : '')]" type="submit">
<i class="far fa-save"></i> Guardar
</button>
that should be work
cv
Docs Updated: http://vee-validate.logaretm.com/v2/guide/flags.html
Most helpful comment
You can use the flags to implement this:
http://vee-validate.logaretm.com/examples.html#flags-example
You could use the
validatedandvalidflags combination to produce the desired result.