djcaesar9114
djcaesar9114

Reputation: 2137

How to remove the error hint on input focus in vueJS

I'd like to remove the error when I have focus on my input. Here is my input:

      <v-text-field
        v-model="models.codePostal"
        label="Code postal"
        :rules="regles.codePostal"
        :hint="this.models.communeResidence.codePostal!==''?`Pourrait être ${this.models.communeResidence.codePostal}`:''"
        hide-details="auto"></v-text-field>

I thought I could add

@focus="error=false"

But it doesn't work. Does anybody have an idea? It may not be possible. Thanks.

Upvotes: 0

Views: 1896

Answers (1)

Lana
Lana

Reputation: 1267

Use reset method on focus event.

<v-text-field
  @focus="reset()"
  ref="field"
  v-model="models.codePostal"
  label="Code postal"
  :rules="regles.codePostal"
  :hint="this.models.communeResidence.codePostal!==''?`Pourrait être ${this.models.communeResidence.codePostal}`:''"
  hide-details="auto"
></v-text-field>
 methods: {
    reset() {
      this.$refs.field.reset()
    }

Or resetValidation() method in the same way if you don't want to clear the field.

Upvotes: 2

Related Questions