To use this script on your own page, click in the text area below, select all, and copy to grab the script. Then, just paste into your own page — and you're done.
See it run: Making Fields Required
This HTML page contains form fields that are required to be filled out by the user before the form can be submitted.
This CSS file sets the style for invalid form elements.
This JavaScript does the form checking. It serves as the basis for all the rest of the examples in this chapter.