Answer the question
In order to leave comments, you need to log in
Vue, vualidate how to start validation?
Good day! I can't figure out how to validate on vue3. In the vualidate examples, everything is on a different level, but I have a simple html page.
There is a form on it, on the form the v-on:submit event (submit is processed, there is an event), in the js vue body:
methods: {
send: function (e) {
alert('Go');
return false;
}
},
validations () {
return {
surname: { requaried },
name: { requaried },
phone: {
requaried,
minLength: minLength(11),
}
}
}
Answer the question
In order to leave comments, you need to log in
vuelidate looks at your properties in data(){} and makes the properties computed, subscribing to them when you specify them in the corresponding validations object.
Example:
data() {
return {
name: '',
},
},
validations() {
return {
name: { required },
},
},
<input type="text" v-model="name" @input="$v.name.$touch()"/>
<input type="text" v-model="$v.name.$model"/>
$v.name.required;
$v.$invalid
, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question