[Vuejs]-How to validate password field with every character in Vuejs?

0👍

Put @change on your repeatPassword input:

v-model="repeatPassword" 
@input="$v.repeatPassword.$touch" 
@change="comparePasswords" // Add this trigger

And add a method:

comparePasswords: function () {

  for (var i = 0; i < this.repeatPassword.length; i++) {
    if(this.password.charAt(i) != this.repeatPassword.charAt(i)) {
      alert("Char at pos " + (i + 1) + " does not match");
    }
  }

}

It will compare char by char.

Leave a comment