Created
September 22, 2010 05:52
-
-
Save philoye/591216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery Plugin: Don't Confirm Passwords | |
// | |
// This marginally useful plugin might be helpful if you don't want to make users type password twice, | |
// but can't change the backend. The server still gets two password values. | |
// | |
// 1. This should unobtrusively hide a confirm password field and update its value based on the password field. | |
// 2. It assumes HTML of the following sort: | |
// | |
// <fieldset> | |
// <ul id="password-wrapper"> | |
// <li> | |
// <label for="choose-password">Choose a password</label> | |
// <input name="password" type="password" id="choose-password"> | |
// </li> | |
// <li> | |
// <label for="confirm-password">Confirm your password</label> | |
// <input name="passwordConf" type="password" id="confirm-password"> | |
// </li> | |
// </ul> | |
// </fieldset> | |
(function( $ ){ | |
$.fn.dontConfirmPasswords = function() { | |
return this.each(function() { | |
var $container = $(this), | |
$pw_container = $(this).children(":first"), | |
$cpw_container = $(this).children(":last").hide(), | |
$pw_field = $pw_container.children("input[type=password]:first"), | |
$conf_pw = $cpw_container.children("input[type=password]:last"); | |
$pw_field.bind("change keyup", function() { | |
$conf_pw.val( $(this).val() ); | |
}); | |
}); | |
}; | |
})( jQuery ); | |
$(document).ready(function(){ | |
$("#password-wrapper").dontConfirmPasswords(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment