[Vuejs]-I want to display an error message when an email address exists in a Vuetiify form

0👍

I wanted to do the same thing before, and here’s my solution:

methods: {
    checkemail() {
      axios
        .get("/api/v1/auth")
        .then((response) => {
          this.emails = response.data.map((a) => 
          a.email);
        });
    },
},

This function return an Array of all the emails

  data() {
    return {
      //email input v-model
      email: "",
      //declare the emails array
      emails: [],
      rules: [
        // your rules
        (v) =>
          (v && this.emails.indexOf(this.email)<0)||
          "this email is already existing",
      ],

I hope that helps

Leave a comment