Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create HTML for a "show password" functionality? [duplicate]

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?

like image 818
sergserg Avatar asked Jan 13 '13 16:01

sergserg


People also ask

How do you create a password entry in HTML?

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.

How do passwords work in HTML?

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.


1 Answers

You can't change type attribute.. See workaround here : http://jsfiddle.net/Ngtp7/2/

and a variation here : http://jsfiddle.net/Ngtp7/

like image 66
Anujith Avatar answered Oct 19 '22 23:10

Anujith