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

The hints do not hide after typing 8 characters and refocusing. Can someone check my code please?

Can't figure out if it is my browser(safari) that will not update or if the problem is in my code. I have also tried clearing cache. Thanks for any help!

//Problem: Hints are shown even when form is valid.
//Solution: Hide and show them at appropriate times.


//Hide hints
$("form span").hide();

//When even happens on password input
$("#password").focus(function(){
  //Find out if password is valid
  if($(this).val().length > 8) {
    //If password is valid, Hide hints
    $(this).next().hide();
  } else {
    //Else show hints
    $(this).next().show();
  }                   
});


//When event happens on confirmation input
  //Find out if passwords match
     //If match hide hint
     //Else show hint

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

According to your code it should only hide if the length is greater than 8. Not equal to 8. Try making this adjustment:

if($(this).val().length >= 8)

Thanks for the quick response Jennifer! My question was not phrased correctly. I wanted it to be longer than 8 characters. I kept going and somehow fixed the problem.. No direct adjustment, but it was fixed somewhere. Ha. Thanks again!