[Vuejs]-How to validate on input event with vee validate 3

0👍

The default is to validate on input already, so what you want to do is trigger the validation yourself, get the result, and then emit your event:

    <ValidationProvider v-slot="{ errors, validate }" name="question" rules="required|max:10000">
        <e-form-group :error="errors[0]">
            <template v-slot:label>
                Question Text
            </template>
            <e-textarea
                v-model="question"
                name="question"
                size="small"
                @input="onInput($event, validate, name)"
            ></e-textarea>
        </e-form-group>
    </ValidationProvider>


methods: {
    onInput(event, validate, name) {
        var self = this;
        validate(event).then(function(result) {
            if (result.valid) self.$emit({questionId: self.questionId, name: name})
        });
    },
},

Leave a comment