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

Jeremy V
Jeremy V
11,110 Points

Why not use focusout event?

My first attempt at this project involved me writing essentially the same code as in the video, except I used the focusout (as shown below) event instead of using focus and keyup.

$("#password).focusout(function() { }

It seems to work just as well. Is there any reason not to do something like this? I know that by creating the function, he is able to reuse the code for both focus and keyup, which may be why he chose to do it that way. But is focusout just as effective for something like this?

Thanks,

Jeremy

2 Answers

Tushar Singh
PLUS
Tushar Singh
Courses Plus Student 8,692 Points

Whenever you have a doubt about something, head over to the documentation pages, and just by examples You will understand various events.

keyup and focus are entirely different.

Take a look at these links and you'll know what to use and what not to. Good Luck mate.

http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_focusout

http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_event_keydown_keyup

Jonathan Fowler
Jonathan Fowler
1,284 Points

Yes I saved a lot of time just using focusout. So simple. Just replace focus with focusout!!