Possible Duplicate:
JQuery change type of input field
Demo here:
http://jsbin.com/welcome/73795/edit
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<input type="password" name="password" />
<button>Show Password</button>
$(document).ready(function() {
$('button').click(function() {
$('input').attr('type', 'text');
});
});
I'm trying to create a button (or checkbox) that users will be able to toggle to see their password written in plain text.
This is basically for portable devices where typing in passwords is a pain, and seeing it in plain text while writing is a UX improvement.
In my example above, changing the type of the input doesn't work.
Any suggestions on how to tackle this problem?
The <input> tag with a type="password" attribute creates a text field where users can securily enter a password. As characters are entered, they are replaced by a dot ("•") or asterisk ("*") symbol, depending on the browser.
Complete HTML/CSS Course 2022 We use the <input> tag by assigning password to the type attribute, to take a password input in HTML form. It hides the character as soon as a we enter the characters of the password set. This is also a single-line text input.
You can't change type
attribute..
See workaround here : http://jsfiddle.net/Ngtp7/2/
and a variation here : http://jsfiddle.net/Ngtp7/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With