R
R
Ruslan Ivanov2022-01-20 18:45:01
Vue.js
Ruslan Ivanov, 2022-01-20 18:45:01

How to implement validation with vuelidate?

61e9813349ed5423530498.png

Attached the handler to the form

<form @submit.prevent="checkForm">

methods: {
    checkForm() {
      this.$v.form.$touch();
      if (!this.$v.form.$error) {
        console.log("Валидация прошла успешно");
      }
    },
  },


Connected the library

<script>
import useVuelidate from "@vuelidate/core";
import { required, email } from "@vuelidate/validators";

export default {
  name: "App",
  setup() {
    return { v$: useVuelidate() };
  },
validations() {
    return {
      form: {
        surname: {},
        name: { required },
}


And I still get an error in the photo. What can be wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question