0

i using vee-validate of my project. But I'm hanging out.

I have 3 input fields. When only 1 of these fields is valid, the other inputs must be valid.

Ex. Like jquery

Jquery validation groups

1 Answers1

0

I found the correct solution:

HTML CODE

<input type="text" name="mobilePhone" class="form-control" v-model="form.mobilePhone" v-validate ="{ rules: { required: contactInfo} }" :class="{'input': true, 'is-danger': errors.has('mobilePhone') }">

<input type="text" name="emailAddress" class="form-control" v-model="form.emailAddress" v-validate ="{ rules: { required: contactInfo} }" :class="{'input': true, 'is-danger': errors.has('emailAddress') }">

<input type="text" name="phoneNumber" class="form-control" v-model="form.phoneNumber" v-validate ="{ rules: { required: contactInfo} }" :class="{'input': true, 'is-danger': errors.has('phoneNumber') }">

JS Computed code

computed: {
    contactInfo () {
      if (this.form.phoneNumber || this.form.mobilePhone || this.form.emailAddress) {
        return false
      }
      else {
        return true
      }
    }
  }
Chadd
  • 636
  • 7
  • 30