Lesson 15. Using JavaScript in Your Pages

Now that you have some understanding of what JavaScript is all about, you’re ready to look at some practical applications of JavaScript.

In this lesson, you learn how to complete the following tasks:

• Validate the contents of a form

• Create a list that expands and collapses

• Modify the styles of elements on a page dynamically

Validating Forms with JavaScript

Remember the example form that you created back in Lesson 11, “Designing Forms?” It’s shown again in Figure 15.1. It’s a typical registration form for a website with several required fields.

Figure 15.1 The registration form.

image

What happens when ...

Get Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day: Includes New HTML5 Coverage, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.