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 2

Tomas Vorel
Tomas Vorel
10,543 Points

Second hint is not showing

Hi fellow coders!

I have to admit that I getting pretty confused while trying to grasp the idea behind jQuery.

In this exercise I cannot get my second hint to show. I tried to follow Andrew step by step but I must have missed something. Could you tell me where did I go wrong?

Here is my code (don't mind the poorly written comments :) ):

//Problem: Hints are shown even when form is valid //Solution: Hide and show them at approriate times var $password = $("#password"); var $confirmPassword = $("#confirm_password"); //Hide hints $("form span").hide();

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

function confirmPasswordEvent () { //Find out if password and confirmation match if($password.val() === $confirmPassword.val()) { //Hide hint if match $confirmPassword.next().hide(); } else { //Else show hint
$confirmPassword.next().show(); } }

//When event happens on password input $("#password").focus(passwordEvent).keyup(passwordEvent).focus(confirmPasswordEvent).keyup(confirmationPasswordEvent);

//When event happens on confirmation input $("#confirm_password").focus(confirmPasswordEvent).keyup(confirmnPasswordEvent);

Steven Parker
Steven Parker
231,275 Points

Use the instructions for formatting code in the Markdown Cheatsheet found below the "Ask to Answer" area. :arrow_heading_down:

2 Answers

Cory Harkins
Cory Harkins
16,500 Points

$("#confirm_password").focus(confirmPasswordEvent).keyup(confirmnPasswordEvent);

Cory Harkins
Cory Harkins
16,500 Points

So your issues are on this line as well :

$("#password").focus(passwordEvent).keyup(passwordEvent).focus(confirmPasswordEvent).keyup(confirmationPasswordEvent);

Error is that confirmationPasswordEvent is not defined... should be confirmPasswordEvent