
Forms appear all over the web. However, they often lack one essential element: validation. Form validation is quite important for both web users and developers. Users are guided by receiving clearly stated responses to errors, while developers will find that validation keeps bad data out of the data source.
There are several different kinds of form validation. Perhaps the most frequently applied type of validation is one that ensures that users fill out required fields correctly. Other validations specify which characters users can or cannot use in an entry, or ensure that users only enter a certain format (such as for a date).
Macromedia Dreamweaver has included a Validate Form client-side behavior since its very first release. Although this degree of form validation is conveniently built-in, the behavior itself is limited in its functionality. For example, you cannot ensure that users make a choice from a pop-up menu. Moreover, you can only check for the presence of text, number, or number range in any given field; you cannot validate an entered phone number, credit card number, or social security number.
Built by WebAssist, the WA Validation Toolkit offers both client-side and server-side validation methods. It supports the ASP-VBScript, ASP-JavaScript, ColdFusion, and PHP server models, and ships with 15 validation behaviors, including the ability to create custom validations with regular expressions. All behaviors work in conjunction with five different response behaviors to alert users when they have entered invalid content into a form, or perform other actions such as enabling or disabling another form element. If you have DRK Volume 9, it contains the WA Validation Toolkit Recipes, which are a series of step-by-step instructions that show you how to get the most out of the WA Validation Toolkit.
For ease of use, the WA Client Validations Wizard portion of the toolkit can't be beat. In three steps, it configures and applies selected validation behaviors along with the Show Validation Errors behavior to a specified form on your page. Additionally, existing WA form validation behaviors on the page that are applied to the onSubmit event of a selected form—either separately or through the wizard—are inspected and can be edited using the wizard. The WA Client Validations Wizard provides a clear and simple path to straightforward client-side validation.
This article explores the WA Validation Toolkit and shows you how to combine both server-side and client-side form validations for a better user experience that can eliminate browser errors for your users and prevent bad data for you.
To complete this tutorial you will need to install the following software and files:
Joseph Lowery's books about the web and web-building tools are international bestsellers, having sold more than 400,000 copies worldwide in eleven different languages. His most recent book is the Dreamweaver CS3 Bible. Joseph is the author of the recently published CSS Hacks and Filters as well as the co-author of Dreamweaver 8 Recipes with Eric Ott. A well-known speaker, he was presented at Adobe (formerly Macromedia) conferences in the United States and Europe as well as user groups around the country. Joseph is currently the Vice President of Marketing for WebAssist.