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

The basics of sanitizing user input - JavaScript Tutorial

From the course: JavaScript for Web Designers

Start my 1-month free trial

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…

Contents