9. Validating Form Data
In the previous chapter, we read data entered by the user with Web forms that display controls such as text fields. In this chapter, we’ll see how to check that data—that is, validate it—before working with it.
For example, you may have an application that lets you create new users on the fly if people enter a username, email address, and password. As this chapter shows, you can check to make sure that the email address is valid before accepting it. You can also ask the user to enter the password twice and then verify that the two entries match before accepting the password. Similarly, you can check to make sure that the username a new user specifies doesn’t already exist in your application.
To validate data items that ...