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.


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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.