Developing Reusable Form Creation Routines

As promised, in this section we will examine reusable methods to create HTML forms with the proper form fields, complete with client-side form validation. These methods will hide the specific details of properly naming form fields and will not bother the developer with creating client-side form validation routines.

Form Implementation Complexity

Usually, creating a form is a trivial task; it’s just a matter of HTML coding. However, due to our reusable server-side validation code, creating a form has become a much more complex issue. When using a global server-side form validation page that all forms initially submit to, all the forms need to follow a certain standard. Specifically, the NAME of each form element that requires form validation must contain an exclamation point followed by the validation regular expression. Furthermore, the form’s ACTION property must direct to the validation page ( /CODEREUSE/ValidateForm.asp) and pass two HIDDEN variables: Collection and Redirect.

Remembering these specific details is cumbersome and serves as an easy place to make a mistake, resulting in a bug. Also, if other developers are to be working on creating the HTML forms, they will be less familiar with the conventions specified by the server-side form validation script, /CODEREUSE/ValidateForm.asp.

As discussed earlier, client-side form validation is a nice option, although not as critical as server-side form validation. As with server-side form ...

Get Designing Active Server Pages now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.