From the course: JavaScript for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Disabling and enabling fields

Disabling and enabling fields - JavaScript Tutorial

From the course: JavaScript for Web Designers

Start my 1-month free trial

Disabling and enabling fields

- [Instructor] We're going to take things up a notch now. Still enforcing the same requirement that the state field be filled in, but our approach will be more forceful. We're going to disable the estimate total button when the page loads and enable it again, once the selection is made. To do this, we're going to listen to a different event. An event called dom content loaded. We're going to listen for this on the document itself. So, we're going to call document dot add add event listener, and the event we're going to listen for is dom content loaded. This is the event that's called when the page is loaded sufficiently that the dom is ready for us. The images might not have loaded. If we want that, we'd generally be using the load event, but dom content loaded is what we can listen for when we just want to make sure that our form element are ready for us to start adding event listeners to them and so forth. And for…

Contents