Skip to content Skip to sidebar Skip to footer

How To Validate Password Field With Every Character In Vuejs?

This my code pen link https://codepen.io/santoshch/pen/bGgKNWV the code is already validating both password fields, if there is mismatch in input it display as must be identical. B

Solution 1:

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.


Post a Comment for "How To Validate Password Field With Every Character In Vuejs?"