I want to make password input using type 'text' not 'password.
<input type="text" v-model="form.password" @input="test" />
<input type="hidden" v-model="form.hiddenPassword" />
So I made some methods for my goal. When I put 'a', it be changed to * and 'a' is in hiddenPassword.
test(e) {
if (e.inputType === "deleteContentBackward") {
this.form.hiddenPassword = this.form.hiddenPassword.substr(
0,
this.form.hiddenPassword.length - 1
);
this.form.password = this.masking(this.form.hiddenPassword);
console.log(this.form.hiddenPassword);
} else {
this.form.hiddenPassword =
this.form.hiddenPassword +
this.form.password.substr(this.form.password.length - 1);
this.form.password = this.masking(this.form.hiddenPassword);
}
},
masking(input) {
const lng = input.length;
let maskingResult = "";
maskingResult += "*".repeat(lng);
return maskingResult;
}
This works well. But the unique problem is that when I want to delete all password in input using Ctrl+A and Backspace, the delete works only one letter by my methods.
I don't know how can I catch Ctrl+A or select some range situation by mouse to delete password.
Could you give me some solution for this? THank you so much for reading it.