Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <style type="text/css">
- #password {
- border: 1px solid #f00;
- }
- </style>
- </head>
- <body>
- <input type="password" name="password" id="password" class="showpassword" />
- </body>
- <script type="text/javascript">
- $(function(){
- $(".showpassword").each(function(index,input) {
- var $input = $(input);
- $('<label class="showpasswordlabel"/>').append(
- $("<input type='checkbox' class='showpasswordcheckbox' />").click(function() {
- var change = $(this).is(":checked") ? "text" : "password";
- var rep = $("<input type='" + change + "' />")
- .attr("id", $input.attr("id"))
- .attr("name", $input.attr("name"))
- .attr('class', $input.attr('class'))
- .val($input.val())
- .insertBefore($input);
- $input.remove();
- $input = rep;
- })
- ).append($("<span/>").text("Show password")).insertAfter($input);
- });
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement