Form Validator R2.0

Jake Howlett, 19 March 2001

Category: Forms; Keywords: JavaScript Validate Submit

This database demonstrates an alternative method of using JavaScript to validate domino forms before their submission to the server. The difference with this database being that the validation routines are totally modular. All you need to do is pass an array of fields in to a JavaScript function and it will do the rest.

The norm seems to be to write a function that checks the value of each field explicitly, which, as discussed in this article, can mean having to write very long functions. For forms with lots of fields this also means editing the function whenever new fields are added to or removed from the form.

Using this method the validation function simply receives an array of fields as an argument and loops through this array whilst validating each field.

The array also includes information on the type of data that is expected so that domino doesn't get upset with text in a number field or a non-date in a date field. There is also an option for each number or date field checked to make sure it is within a certain range.

The routines in the database can handle the following field types:As well as the following types of data:Take a look at the database to see what I mean. It is developed in R5 but the code and principles should work in all versions of both client and browser.

Note that the later version are very JavaScript intensive and, if you want to get "under the hood", not for the lighthearted. However, you can use it simply by copying all the ".js" pages into your database and then call the functions from any form in your databases.

Current Version:
Version 20. introduces support for Netscape, both version 4.5 and 6.0. There are also a few smaller fixes, including a bug with single radio-buttons and check-boxes. The new CSS files provide a new look to distinguish this from prior versions.

Previous Version:
Version 1.8 introduced the principle of using arrays to store the fields that need validating.

Version 1.6 introduced the ability to validate various data types.

Version 1.5 introduced the ability to specify which fields are to be validated, using the field's ID attribute to store various information.

Version 1.0 was the original idea and worked by simply looping through every field in the form and checked for an entry.