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 trialLouis Rosenstein
6,343 PointsPassword confirmation hint hide/show stopped working
So I was following along, and at about the 3:30 mark in the video when he checks to see if everything is still working fine my code was broken, I'm having trouble figuring out where I messed up. I think it's somewhere in the confirmPasswordEvent() function. Please help, thanks!
var $password = $("#password");
var $confirmPassword = $("#confirm_password");
//Hide hints
$("form span").hide();
function isPasswordValid() {
return $password.val().length > 8;
}
function arePasswordsMatching() {
$password.val() === $confirmPassword.val();
}
function passwordEvent() {
//Find out if password is valid
if(isPasswordValid()) {
//Hide hint if valid
$password.next().hide();
} else {
//Else show hint
$password.next().show();
}
}
function confirmPasswordEvent() {
//Find out if password and confirmation match
if(arePasswordsMatching()) {
//Hide hint if matched
$confirmPassword.next().hide();
} else {
//else show hint
$confirmPassword.next().show();
}
}
//When event happens on password input
$password.focus(passwordEvent).keyup(passwordEvent).focus(confirmPasswordEvent).keyup(confirmPasswordEvent);
//When event happens on confirmation input
$confirmPassword.focus(confirmPasswordEvent).keyup(confirmPasswordEvent);
Louis Rosenstein
6,343 PointsLouis Rosenstein
6,343 PointsAhhh ok silly error on my part. Thank you!!