Utilizing bootstrap.vue components, specifically "b-form-input", I am trying to implement a feature to hide and show the password by clicking the button attached to the input field. While this functionality works with a regular input field, I am facing challenges when using it with "b-form-input". The approach of using "v-bind:type=..." did not yield the desired results. How can I tackle this issue?
https://i.sstatic.net/NY9oW.png
https://i.sstatic.net/QEALZ.png
This is my current code:
<b-input-group>
<input v-bind:type="[showPassword ? 'text' : 'password']">
<b-input-group-append>
<b-button @click="showPassword = !showPassword" size="sm" variant="outline-success">show</b-button>
</b-input-group-append>
</b-input-group>
Update: Below is the updated code (quick and dirty implementation):
showPassword(){
if (this.inputtype === "text") {
this.inputtype = "password"
}
if (this.inputtype === "password") {
this.inputtype = "text"
}
console.log("in show PW ... ")
},
HTML:
<b-input-group>
<b-form-input :type="inputtype"
:id="`type-${inputtype}`">
</b-form-input>
<b-input-group-append>
<b-button @click="showPassword()"
size="sm"
variant="outline-success"
>
show
</b-button>
</b-input-group-append>
</b-input-group>