4

I have been trying to use vee-validate with scope on Veutify form. But when the form is submitted it doesn't show any error or the form is always valid.

I think i miss something on my implementation.

Please help.

<div id="app">
 <v-app id="inspire">
 <form data-vv-scope="form1">
 <v-text-field
 v-model="name"
 label="Name"
 :counter="10"
 :error-messages="errors.collect('form1.name')"
 v-validate="'required|max:10'"
 data-vv-name="name"
 required
 ></v-text-field>
 <v-btn @click.native="submit('form1')">submit</v-btn>
 <v-btn @click="clear">clear</v-btn>
 </form>
 </v-app>
</div>

Submit Method:

submit(scope) {
 alert("submit");
 this.$validator.validateAll(scope).then(result => {
 if (result) {
 }
 });
}

Sample Code

asked Apr 28, 2018 at 7:55
1

2 Answers 2

1

It is not inherently obvious from the documentation, https://baianat.github.io/vee-validate/examples/scopes.html, or from the examples provided, https://codesandbox.io/s/y3504yr0l1?from-embed, especially when using within Vuetify.

When you define data-vv-name it needs to be prefixed with the scope.

data-vv-name="form1.name"
answered Aug 20, 2019 at 13:50
Sign up to request clarification or add additional context in comments.

Comments

0

I think you should use validator.validate('scope.*') instead of $validator.validateAll('scope');

you may refer to this link https://vee-validate.logaretm.com/v2/api/validator.html#methods

answered Apr 23, 2021 at 7:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.