Advertisement
Guest User

jQuery - Show/Hide Password Demo

a guest
Apr 4th, 2015
1,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>jQuery - Show/Hide Password Demo</title>
  5.    
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  7.     <script type="text/javascript">
  8.         $(document).ready(function() {
  9.             $("#showHide").click(function() {
  10.                 if ($(".password").attr("type") == "password") {
  11.                     $(".password").attr("type", "text");
  12.  
  13.                 } else {
  14.                     $(".password").attr("type", "password");
  15.                 }
  16.             });
  17.         });
  18.     </script>
  19.  
  20.     <style type="text/css">
  21.         #showHide {
  22.             width: 15px;
  23.             height: 15px;
  24.             float: left;
  25.         }
  26.         #showHideLabel {
  27.             float: left;
  28.             padding-left: 5px;
  29.         }
  30.     </style>
  31. </head>
  32.  
  33. <body>
  34.     <table>
  35.         <tr>
  36.             <td>Password:</td>
  37.             <td><input type="password" name="password" class="password" size="25"></td>
  38.         </tr>
  39.         <tr>
  40.             <td></td>
  41.             <td>
  42.                 <input type="checkbox" id="showHide" />
  43.                 <label for="showHide" id="showHideLabel">Show Password</label>
  44.             </td>
  45.         </tr>
  46.     </table>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement