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.
<head> of your page like so:
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.
validators, which contains the regular expressions and/or functions to validate each field that needs it.
matchfields, which maps password fields so that two will automatically be compared, a functionality often required in forms.
- And last is the array
messages, which will contain the error messages for your form-fields. As is also described in the script file, \1 will be replaced by the name of the form-field if you should desire such.
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);">.