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 - JavaScript Tutorial
From the course: JavaScript for Web Designers
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Working with user info4m 44s
-
Text fields and select boxes5m 45s
-
(Locked)
Radio buttons and checkboxes5m 30s
-
(Locked)
Changing submission with events4m 21s
-
(Locked)
Starting to validate input4m 15s
-
(Locked)
Disabling and enabling fields5m 14s
-
(Locked)
The basics of sanitizing user input7m 1s
-
(Locked)
Get and set with innerHTML6m 58s
-
(Locked)
Challenge: Add and use more fields56s
-
(Locked)
Solution: Add and use more fields3m 23s
-
(Locked)
-
-
-
-