CHAPTER 9

image

Performing Form Validation with Regular Expressions

It’s your responsibility as a developer to ensure that your users’ data is useful to your app, so you need to confirm that critical information is validated before storing it in your database.

In the case of the calendar application, the date format is critical: if the format isn’t correct, the app will fail in several places. To verify that only valid dates are allowed into the database, you’ll use regular expressions (regexes), which are powerful pattern-matching tools that allow developers much more control over data than a strict string comparison search.

Before you can get started ...

Get Pro PHP and jQuery, Second Edition 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.