Jquery Password field disappearing default


/ Published in: JavaScript
Save to your folder(s)

There are two input fields for password.. One is of type text and the other is password. Their visibility is basically toggled.


Copy this code and paste it in your HTML
  1. <!-- HTML -->
  2. <input id="password-clear" type="text" value="Password" autocomplete="off" />
  3. <input id="password-password" type="password" name="password" value="" autocomplete="off" />
  4.  
  5. // CSS
  6.  
  7. #password-clear {
  8. display: none;
  9. }
  10.  
  11. // JQUERY
  12.  
  13. $('#password-clear').show();
  14. $('#password-password').hide();
  15.  
  16. $('#password-clear').focus(function() {
  17. $('#password-clear').hide();
  18. $('#password-password').show();
  19. $('#password-password').focus();
  20. });
  21. $('#password-password').blur(function() {
  22. if($('#password-password').val() == '') {
  23. $('#password-clear').show();
  24. $('#password-password').hide();
  25. }
  26. });

URL: http://www.electrictoolbox.com/jquery-toggle-between-password-text-field/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.