Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript jQuery Basics (2014) Creating a Password Confirmation Form Perform: Part 2

$password.focus(passwordEvent).keyup(passwordEvent).focus(confirmPasswordEvent).keyup(confirmPasswordEvent);

Hello,

I can't understand this line very well.

I understand why the () is not necessary at the end of "passwordEvent" and "confirmPasswordEvent" but I don't know how this line works.

Could you help me please?

Thank you.

I'm not sure if this is correct, but basically my understanding of what happens is this:

1) when the password field is selected, it calls the passwordEvent function to check if the password is valid (i.e. has more than 8 characters) and to hide/show the hint. 2) after each keypress, it calls the passwordEvent function to check if the password is valid and to hide/show the hint.

That's what it was doing before, but the problem was that if you wrote the password, wrote the confirmation, and then changed the password in the first field, the tips would no longer be correct.

So we add the confirmPasswordEvent function to the inputs on the password field.

3) when the password field is selected, it calls the confirmPasswordEvent function to check if the password and the password confirmation are the same 4) after each keypress, it calls the confirmPasswordEvent function to check if the password and the password confirmation are the same.

This makes it so if things match, and then a change is made so that they don't, the system provides the appropriate tip.