Chapter 3: Validating Web Forms with JavaScript and PHP

In This Chapter

arrow.png Considering important web form validation issues

arrow.png Using JavaScript validation

arrow.png Using PHP validation

When you put a web form out on the Internet, you’re inviting people to send you information. Unfortunately, not everyone fills out web forms correctly; some people don’t know how the phone number should be formatted or whether to use a five-digit or nine-digit ZIP code. In addition to basic mistakes, there are also malicious users who fill out forms incorrectly to see if they can get your program to break or if they can access data that they shouldn’t.

Regardless of the reason why forms might be filled out with incorrect information, it’s up to you, the developer, to make sure that the data is formatted correctly prior to acting on it. For example, if someone fills out a form with letters instead of numbers for a ZIP code, chances are that you want to return some type of error message to have that user fix the issue.

This chapter tells you what important items to consider when you’re deciding |how to validate your web forms, how to set up JavaScript validation and provide feedback to form users, and how to validate ...

Get PHP, MySQL, JavaScript & HTML5 All-in-One For Dummies 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.