How can I write code so that if user clicks on eye icons the password type changes to text and vice-versa ? | SoloLearn: Learn to code for FREE!

+2

How can I write code so that if user clicks on eye icons the password type changes to text and vice-versa ?

https://code.sololearn.com/Wqr7LFJ0ETJ3/?ref=app

5/18/2020 1:36:31 PM

Abhay Rao

5 Answers

New Answer

+2

Check it now. https://code.sololearn.com/Wqr7LFJ0ETJ3/?ref=app

+1

add an eye icon and then add an event listener to the eye icon to toggle the input type attribute from password to text or text to password.

+1

add state to check if the field is set to password and the change it to text or if it is text, change it to password. The state could be something like “let isTypePassword = true” and toggle from true to false when the eye is clicked.

+1

https://code.sololearn.com/WF00189f1bJm/?ref=app

+1

How can I do it in Jqeury ?