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.

Starting to validate input

Starting to validate input - JavaScript Tutorial

From the course: JavaScript for Web Designers

Start my 1-month free trial

Starting to validate input

- We aren't yet taking proper action to deal with the data in this form, so it's time to do that, starting with Form Validation, the term for code that inspects what data are in the form, validates that it's what we're expecting, and cleaning it up, if needed. Here, we're going to start by making sure that the user has selected a state, before they try to get their estimate. Switching back over to my code, I'm going to be taking this action inside my estimate total function, so I'm going to get rid of this console.log. We're going to replace it with something meaningful. I'm going to start by saving a reference to that state field that I'm going to be taking some actions on. So I'll say var state is document.getelementbyID, and we need the ID. Let's go back over to the browser, and inspect this item. All right, we'll double click to select its ID, and then copy it. Close these tools again. I'll paste it…

Contents