1

I want to check if form is valid using vee-validate. I am currently doing it like this:

<button type="submit" :disabled="errors.count()">

But when the form is created and not validated yet, errors.count() return 0, meaning that the button stays enabled until the user modifies a field. Is there any way to validate it at start?

1 Answer 1

5

I dont find any vee-validate api for that. So that's why I have to fixed this issue by doing this way.

Vue.component("form", {
    computed: { 
        isFormInvalid:function () {
           return this.errors.count() > 0 || !(Object.keys(this.fields).some(key => this.fields[key].dirty));
       }
    }
});

<button type="submit" :disabled="isFormInvalid">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.