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 that signs up guests for 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 product, you want to be sure that your visitor includes his address on the form.

Luckily, Dreamweaver includes a set of validation options that do exactly that. They’re called Spry validation “widgets.” (The term widget refers to any of the Spry-based, interactive web page elements 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 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 the 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 CS6: 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.