Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  22] [ 3]  / answers: 1 / hits: 31720  / 15 Years ago, sat, september 5, 2009, 12:00:00

I have a usual login form consisting of two input fields, one for login, one for password. I am currently trying to add a control that will show entered password as plain text, so user can check it for typos.



The problem is that browsers (at least Firefox) do not allow dynamic changing of type attribute of input fields, so I cannot just change type=password to type=text. Another problem is that browsers do not allow to get value of password field, so I can't create a new input type=text and set its value to the password's one. I've seen several different approaches to this task, including this one, but they are working only if the password is typed and fail when browser autofills the password.



So, any suggestions to do this are welcome. I am using jQuery.


More From » jquery

 Answers
9

You can do something like this:



<input type=password id=password>
<input type=checkbox onchange=document.getElementById('password').type = this.checked ? 'text' : 'password'> Show password

[#98754] Tuesday, September 1, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eliezerc

Total Points: 286
Total Questions: 102
Total Answers: 102

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
eliezerc questions
Mon, Jun 20, 22, 00:00, 2 Years ago
Fri, Sep 4, 20, 00:00, 4 Years ago
Fri, Jul 3, 20, 00:00, 4 Years ago
;