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.
The basics of sanitizing user input - JavaScript Tutorial
From the course: JavaScript for Web Designers
The basics of sanitizing user input
- [Instructor] Now we're going to take a look at sanitizing user input, a process that helps prevent unexpected behavior and security problems. If you've been following along with your work-in-progress folder, we're going to need to copy in some code from the script file in the exercise files for this video. I have that version open here. I've fleshed out the estimateTotal function a little bit with some more functionality to give us a little bit of a boost, so, I'm going to select this entire file and paste it into my work-in-progress version. We'll save it, and now we can go over the changes. Down here in estimateTotal, we now are collecting the quantities of all of the items that are in the cart, have all of those saved in variables. I'm collecting the shippingState and the shippingMethod using document.querySelector to pick out which of those radio buttons was checked and get its value. Then, we're doing some…
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)
-
-
-
-