Class 4 Prep

Before coming to Class 4, please complete the following tasks:

Forms

You already have experience working with HTML <form> elements, but it is worth spending some more time on them and seeing how Javascript can fit into the picture.

Done Task Resource Type Link Time Estimate Instructions
Watch Video Interacting With Forms in Javascript 35 minutes Watch this introduction to some of the ways that you can work with forms in your Javascript code
Read Interactive Book EloquentJS 18: Forms 2.5 hours This chapters goes over Javascript's historical and current relationship to forms, and the many different types of <input> that you can put inside a form.

Client-side Validation

The key aspect of front-end (or "client-side") code is that a website can provide instant feedback to the user. A classic use case of Javascript is to perform "client-side validation" of forms: in other words, page can include a script that checks whether the form was properly filled out, and does this locally before bothering to send a request over to the server. That way, the user does not have to wait 3 seconds (an eternity) only to learn that she messed up and needs to fill out the form again. If we know right away, we should tell the user right away.

Task Resource Type Link Time Estimate Instructions
Follow-Along Walkthrough CS50: form-0 15 minutes In this walkthrough video, David Malan from CS50 creates a demo page with a registration form for users to sign up for something. As you watch the video, you should code along with him and make your own version of his project.
Follow-Along Walkthrough CS50: form-1 15 minutes Here we improve our registration form by adding a script that performs client-side validation on the form. NOTE that you will not have a file called register.php, so you will get 404 errors on that part--that's fine, just use your imagination.