Hi,
I have rendered a textbox and set the type to "password". Now I would like to have an icon in the textbox that will show the password when clicked.
I have found one forum thread that is almost what I wanted, but there a button outside the textbox is being used. I want an icon in the textbox.
Is this possible?
|
@using Syncfusion.EJ2
@Html.EJS().TextBox("password").Type("password").Placeholder("Enter the password").Created("onCreate").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Render()
<script>
function onCreate() {
this.addIcon("append", "e-icons e-input-eye");
document.getElementsByClassName("e-input-eye")[0].addEventListener("click", function (e) {
let textObj = document.getElementById("password").ej2_instances[0];
if (textObj.element.type === "password") {
textObj.element.type = "text";
} else {
textObj.element.type = "password";
}
});
}
</script>
<style>
.e-input-eye:before {
content: '\e345';
font-family: e-icons;
font-size: 13px;
}
</style> |
|
@using Syncfusion.EJ2
@Html.EJS().TextBox("password").Type("password").Placeholder("Enter the password").Created("onCreate").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Render()
<script>
function onCreate() {
this.addIcon("append", "e-icons e-input-eye");
document.getElementsByClassName("e-input-eye")[0].addEventListener("click", function (e) {
let textObj = document.getElementById("password").ej2_instances[0];
if (textObj.element.type === "password") {
textObj.element.type = "text";
} else {
textObj.element.type = "password";
}
});
}
</script>
<style>
.e-input-eye:before {
content: '\e345';
font-family: e-icons;
font-size: 13px;
}
</style> |
Thank you. This worked perfectly