This file explain how to use my form-validator script. It's aim is to be fast and simple to implement yet flexible enough to handle most forms. I think I have been able to reach those goals with this version. You should realise that this is my final release, some new ideas to update this validator are being written as we read and will not be 100% backwards compatible. Upgrading to the new version should still be relatively painless however.

Implementing the form-validator I have created is fairly easy and doesn't require a lot of javascript knowledge, some knowledge of regular expression is required to modify the default behavior, ample help-files can be found on the net. Simply right-click and save the script as a text file. Then link it into your page with a simple line of code in the <head> of your page like so: <script type="text/javascript" src="validator.js"></script>.

The script, off course, comes with the default examples as demonstrated on this page, you should overwrite the default settings to reflect your own form. The exact information may be found in the script files itself, but in short summary it comes down to three arrays that you should overwrite yourself.

Last, but certainly not least, you should set your form up for validation by adding an event to it. I will not discuss the more advanced ways of doing so, even though those are desirable, I did not intend to teach people the proper way of adding events in this paper. The most simple way of adding validation will be to add the onsubmit event in-line, like so: <form action="yourchoice" onsubmit="return validate(this);">.

Text-based formfields

These will include all types of freeform text-based formfields. I intend to make several testcases based on simple to advanced expressions.

The following works based upon a more simple validation, if a password field is present in the validators, it will look for an element with the name of the validator and check if that field is equal to the password. As such it doesn't matter if this field is hidden or another password field...

Selection-based formfields

A couple of selection based formfields. Not much validation I can foresee besides mandatory or not.

check1
radio1 radio2 radio3
Complex rule example

Not every rule can be captured in a regular expression, though most of them can be. So in order to allow complex rules, the possibility of providing a custom function instead of a regular expression has been added.

if checked...