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 trialArvin Wallace
8,956 PointsenableSubmitEvent
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
Robert Richey
Courses Plus Student 16,352 PointsHi 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.
Arvin Wallace
8,956 PointsMakes sense Robert,
Thank you!
stephennorquist
7,712 Pointsstephennorquist
7,712 PointsWould 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: