Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

311


Chapter 7 Working with forms


CHAPTER 7 Working with forms


T


he previous chapters cover much basic information regarding HTML document creation
and manipulation. Not explained yet is how to get information back to the server. For
this, you need to understand how forms work and how to create them. This chapter pro-
vides the information you need to accomplish these tasks.

Lessons in this chapter:
■■Lesson 1: Understanding forms 311
■■Lesson 2: Form validation 324

Before you begin


To complete this book, you must have some understanding of web development. This
chapter requires the hardware and software listed in the “System requirements” section in
the book’s Introduction.

Lesson 1: Understanding forms


A form is responsible for collecting data and sending it somewhere. In most cases, the
data is sent back to the server for processing. Because server-side processing hasn’t been
explained yet, you will send the data to an email address instead. This is not a recom-
mended practice; in fact, you should never do this because it exposes your email address to
the public. However, this technique provides an intermediate step in helping you under-
stand the browser side of forms before server-side processing is discussed.
To understand how forms work, you need a basic understanding of how HTTP protocol
works. This lesson provides the necessary introduction to HTTP protocol and then discusses
form implementation.
Free download pdf