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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access