Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShavon Knox
26,039 PointsPassword not hiding after 8 characters
My password is not hiding after the first 8 characters :(
var $password = $("#password");
var $confirmPassword = $("#confirm_password");
$("form span").hide();
function passwordEvent(){
if($password.val().length > 8) {
$($password).next().hide();
} else {
$(this).next().show();
}
}
function confirmPasswordEvent() {
if($password.val() ===$confirmPassword.val()) {
$confirmPassword.next().hide();
}else{
$confirmPassword.next().show();
}
}
$password.focus(passwordEvent).keyup(passwordEvent)
.focus(confirmPasswordEvent).keyup(confirmPasswordEvent);
$confirmPassword.focus(confirmPasswordEvent).keyup(confirmPasswordEvent);
1 Answer
shadryck
12,151 PointsI'm not sure since I barely have used jquery like ever, however I do have to say that I strongly recommend not validating passwords with javascript for various security reasons its a better idea to do this server side with php or such. <br>
If you're new to saving and processing passwords I recommend reading some about blowfish encrypting, hashing and salts. <br> securing passwords with blowfish <br> php blowfish random salted passwords <br> <br> I hope this helps you on your way of secure password processing. <br> shadryck
Rick Gates
11,061 PointsRick Gates
11,061 PointsAlthough you're using the $confirmPassword variable properly, it looks like you're not using the $password variable properly in your code on lines 8 and 10. You've wrapped $password in $() on line 8 and you've used $(this) on line 10.
Corrected code should look like this: