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 jQuery Basics (2014) Creating a Password Confirmation Form Perform: Part 1

John McKinney
John McKinney
15,331 Points

What's wrong with my code?

When I open the preview the hints don't hide at start, they also don't hide when I finish typing in them

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

function passwordEvent(){
  //Find out if password is valid
  if($(this).val().length > 8){
    //Hide if valid
    $(this).next().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 matched
    //Else show hint

1 Answer

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,671 Points

You're missing a curly brace to close off your passwordEvent() function.

function passwordEvent() {
  //Find out if password is valid
  if($(this).val().length > 8) {
    //Hide if valid
    $(this).next().hide();
  } else {
    //Else show hint
    $(this).next().show();
  }
}

Cheers!

–Rich

John McKinney
John McKinney
15,331 Points

Ah thank you! Those typing errors get me

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,671 Points

Most definitely. Check out JS Bin or something similar. This will help tremendously in catching any simple syntax errors we're not aware of.

Jack McDowell
Jack McDowell
37,797 Points

Thanks for the JSBin tip Rich Donnellan, you saved me a lot of hair pulling.

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,671 Points

Glad it was helpful, Jack McDowell! It'll come in handy so much now that you'll wonder how you ever worked without it!