Created
May 15, 2012 21:01
-
-
Save wholypantalones/2705110 to your computer and use it in GitHub Desktop.
Show/Hide password fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <input type="password" id="OLD_PASSWORD" name="OLD_PASSWORD" value="" /> | |
| <input type="checkbox" value="option" id="showPass" name="showPass" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function() { | |
| $("#showPass").click(function() { | |
| if($('#showPass').attr('checked')) { //can use .is(':checked') also | |
| $("input[type=password]").each(function() { //iterate through all of type=password | |
| $(this).clone().attr("type", "text").appendTo($(this).parent()).val($(this).val()); | |
| $(this).remove(); | |
| }); | |
| } else if($('#showPass').is(':not(:checked)')) { | |
| $("input[type=text]").each(function() { | |
| $(this).clone().attr("type", "password").appendTo($(this).parent()).val($(this).val()); | |
| $(this).remove(); | |
| }); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment