If you've got a web page, you've probably got a form. The question is
what to do with it. We'll I've whipped up this little sample to give
a quick illustration of form validation. It's pretty forgiving. For
the most part, if you enter something, it lets it through.
The form processor is built into the same page as the form (a popular
trick which I find myself doing a lot of recently). Although this
sample is pretty simplistic, I've embellished some areas so that it's
a little more confusing... um I mean interesting... yeah that's what I
meant! First, I've used a function to build the form to ensure
consistency and to save myself from my typing! I've also taken
a rather interesting approach of not explicitly retrieving variables.
I loop through the collection using their names as an indicator of
the type of field for the field validator.
One final little feature is a pair of buttons at the bottom of the form
which, when pressed, enter the information for you. The first enters
data which is almost correct but doesn't quite meet our criteria, while
the second enters data which does meet our little set of rules. It
allows you to play with the sample without having to take the time to
fill in the form. After you use it you'll only have two questions.
First, when are real web sites going to start doing this? Second, the
ASP 101 webmasters can write client side script?
If you care, the answer to the second question is that we can, but not
very well... it took me just as long to do the JavaScript as it did to
write the rest of the sample! ;)