I am trying to implement text box for password which has a eye icon( css class- fa fa-eye). when user click on the eye icon it changes to eye slash icon and input type to text.
<div class="input-group show-hide-password">
<form:password id="form-control" path="password" class="form-control" required="" />
<div class="input-group-append">
<span id="PassSpan" class="input-group-text" onclick="typeChange('form-
control','PassSpan')">
<i class="fa fa-eye" aria-hidden="true"></i>
</span>
</div>
</div>
Js file
function typeChange(controlId, spanId) {
var x = document.getElementById(controlId);
if (x.type === "password")
{ x.type = "text";
}
else {
x.type = "password";
}
}
this function only changes the input type but i am not able to change the class to fa fa-eye-slash. fa-eye and fa-eye-slash classes are present on css file. but I am not sure how to change the class of as it is inside span element.
Can someone please help me with that.