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 trial

JavaScript

task 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

On 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();

No spaces of course, just trying to show a little more emphasis on what needs changing.

$(this).next().hide(); hope this will help

Keith Doyle
Keith Doyle
25,973 Points

When you're calling $(this).hide() you're going to hide the password field. You want to call hide() on the hint element instead.