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 trialTapiwa Chinembiri
6,285 Pointstask 1 of 1 on password hints, stuck on this code challenge, It seems the DRY ok i don know where the proplem is.
When I type a password in the password field greater than 8 characters the input disappears not the hint. Fix it.
//Problem: Hints are shown even when form is valid //Solution: Hide and show them at appropriate times
//Hide hints $("form span").hide();
function passwordEvent(){
//Find out if password is valid
if($(this).val().length > 8) {
//Hide hint if valid
$(this).hide();
} else {
//else show hint
$(this).next().show();
}
}
//When event happens on password input $("#password").focus(passwordEvent).keyup(passwordEvent);
//When event happens on confirmation input //Find out if password and confirmation match //Hide hint if match //else show hint
3 Answers
Charles Cunningham
7,322 PointsOn line 11, it's just hiding the current element. In this case, it's the hint. In order to call the next element, it's simply .next()
Code on Line 11 should appear as such:
$(this) .next() .hide();
MUZ140529 Praise Chinoda
5,877 Points$(this).next().hide(); hope this will help
Keith Doyle
25,973 PointsWhen you're calling $(this).hide()
you're going to hide the password field. You want to call hide()
on the hint element instead.
Charles Cunningham
7,322 PointsCharles Cunningham
7,322 PointsNo spaces of course, just trying to show a little more emphasis on what needs changing.