Posted By

ryonley on 07/13/12


Tagged


Versions (?)

Jquery Password field disappearing default


 / Published in: JavaScript
 

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

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

  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. });

Report this snippet  

You need to login to post a comment.