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

CSS jQuery Basics (2014) Creating a Password Confirmation Form Perfect

Arvin Wallace
Arvin Wallace
8,956 Points

enableSubmitEvent

So in the tutorial, enableSubmitEvent() is called after each "key up" and then again all by itself at the end of the document. What is the purpose of calling it at the end of the document if it is called at each "key up"?

2 Answers

Hi Arvin,

Calling enableSubmitEvent() at the bottom like that will call the function once when the page loads, and as a result will disable the submit button, preventing the user from clicking it before entering in their user name and password.

Would giving the Submit button the disabled property in the HTML, as was shown as an example, and then having the function enable it, work just fine without having to call it on the page load?

Here's what I'm thinking:

function submittable(){
  return validUser && validPass && validConfirm;
}
function submitter(){
  $submit.prop('enabled', submittable());
}
Arvin Wallace
Arvin Wallace
8,956 Points

Makes sense Robert,

Thank you!