Validating Forms

You might get frustrated when you review feedback submitted via a form on your web page, only to notice that your visitor failed to provide a name, email address, or some other critical piece of information. That’s why, depending on the type of form you create, you might want to make certain information mandatory.

For instance, a form used for subscribing to an email newsletter isn’t much use if the would-be reader doesn’t type in an email address. Likewise, if you need a shipping address to deliver a brochure or product, you want to be sure that the visitor includes his address on the form.

Luckily, Dreamweaver includes a set of validation options that do exactly this: Spry Validation “widgets.” (The term widget refers to any of the Spry-based, interactive web page element that Dreamweaver helps you create, such as the Spry Menu Bar, Spry Validation Text Field, and Spry Tabbed Panels.) With a Spry Validation widget, you can display a friendly “Hey, please fill out this box” message when someone tries to submit a form that’s missing important information. You can specify that visitors can’t leave a particular field blank, or that a field must contain information in a specific format, such as a phone number, email address, or credit card number. If someone tries to submit a form without the correct information, your message appears. And instead of an annoying and amateurish JavaScript error window popping up, Spry form validation widgets display error messages right ...

Get Dreamweaver CS5: The Missing Manual 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.