Return to Snippet

Revision: 30313
at August 11, 2010 19:11 by Rembrand


Initial Code
//src: http://www.electrictoolbox.com/jquery-toggle-between-password-text-field/

$(document).ready(function () {
  $('#password-clear').show();
  $('#password-password').hide();
		
  $('#password-clear').focus(function() {
    $('#password-clear').hide();
    $('#password-password').show();
    $('#password-password').focus();
  });
  $('#password-password').blur(function() {
    if($('#password-password').val() == '') {
      $('#password-clear').show();
      $('#password-password').hide();
    }
  });
});

---

#password-clear {
    display: none;
}

----

<input id="password-clear" class="form-text default-value" type="text" value="Type your password" autocomplete="off" />
<input id="password-password" class="form-text default-value" type="password" name="password" value="" autocomplete="off" />

Initial URL
http://www.medilab.be/

Initial Description
Originally form http://www.electrictoolbox.com\r\nComes in handy if you want to display a message in the field (\\\"type your password\\\") but mask the password itself.

Initial Title
Switch textfield with a password field  (on focus)

Initial Tags
forms

Initial Language
jQuery