Details
Author: Jake Howlett
Date: 19 March 2001
Article: DFOU-4PRG6R
Category: Forms
Keywords: JavaScript; Validate; Submit;
Attachments
validation15.zip (33 Kbytes)
validation10.zip (14 Kbytes)
validation16.zip (56 Kbytes)
validation18.zip (51 Kbytes)
validation20.zip (65 Kbytes)

Form Validator R2.0


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:
  • Text Fields
  • Single-Select Dropdown Boxes
  • Multi-Select Dropdown Boxes
  • Text-areas
  • Radio Buttons
  • Check Boxes
  • File Uploads
As well as the following types of data:
  • Text
  • Dates
  • Date Ranges
  • Numbers
  • Number Ranges
  • E-mail Addresses
  • File Types
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.

Feedback:

Form Validator R2.0
. . Some minor enhancement suggestions! (David Marsh, Sun 26 Nov 2000)
. . . . Re: Netscape 4 and 6 (Jake, Sat 17 Mar 2001)
. . Problem to be aware of!! (Jake, Fri 16 Mar 2001)
. . Problem with Generate HTML for all Fields (Luis Contreras, Sat 25 Aug 2001)
. . . . Re: Problem with Generate HTML for all Fields (Ove Størholt, Wed 13 Feb 2002)
. . . . . . Re: Problem with Generate HTML for all Fields (Anonymous, Sat 8 Mar 2003)
. . . . Re: Problem with Generate HTML for all Fields (Russ McBride, Thu 23 Oct 2003)
. . JavaScript Form Validator R2.0 (fogg, Fri 31 Aug 2001)
. . . . Re: JavaScript Form Validator R2.0 (dook, Tue 6 Aug 2002)
. . . . . . Re: JavaScript Form Validator R2.0 (Jake Howlett, Wed 7 Aug 2002)
. . Works a treat mate - CHEERS (Matty, Thu 29 Nov 2001)
. . . . Re: Works a treat mate - CHEERS (Jake Howlett, Thu 29 Nov 2001)
. . . . . . Re: Works a treat mate - CHEERS (Matty, Fri 30 Nov 2001)
. . . . Re: Works a treat mate - CHEERS (Mike Bruinsma, Mon 30 Sep 2002)
. . Huge timesaver (David McGrew, Mon 3 Dec 2001)
. . Lifesaver! (Ben, Tue 22 Jan 2002)
. . . . JS Validation - problem with DIV tags (Kathryn Davies, Thu 21 Feb 2002)
. . . . Re: Lifesaver! (Jake Howlett, Tue 22 Jan 2002)
. . . . . . Donation made! (Ben, Mon 4 Feb 2002)
. . Validate a time value : hh:mm am/pm (Matt, Fri 15 Feb 2002)
. . . . Re: Validate a time value : hh:mm am/pm (Chris Key, Mon 25 Feb 2002)
. . . . . . Re: Validate a time value : hh:mm am/pm (Chris Key, Wed 1 May 2002)
. . . . . . . . What's the chances of that... (Jake Howlett, Wed 1 May 2002)
. . . . . . . . . . Re: What's the chances of that... (Kevin Longmuir, Fri 7 Nov 2003)
. . . . . . Re: Validate a time value : hh:mm (Abhijit Tayade, Mon 16 Jul 2007)
. . . . Re: Validate a time value : hh:mm am/pm (Pradeep, Tue 24 Aug 2004)
. . . . Re: Validate a time value : hh:mm am/pm (pankaj, Fri 21 Dec 2007)
. . Justifying Changed Values! (Steve Cochrane, Mon 25 Feb 2002)
. . . . Re: Justifying Changed Values- Solved! (Steve Cochrane, Fri 1 Mar 2002)
. . Netscape 6 not validating (Mike Donovan, Wed 13 Mar 2002)
. . . . Re: Netscape 6 not validating (Thomas, Mon 9 Dec 2002)
. . . . . . Re: Netscape 6 not validating (Jake Howlett, Mon 9 Dec 2002)
. . . . . . Re: Netscape 6 not validating (Randal Oulton, Sun 10 Aug 2003)
. . Similar but different (TippChick, Thu 14 Mar 2002)
. . . . Re: Similar but different (Jake Howlett, Thu 14 Mar 2002)
. . . . Date Validation? (Simon P, Thu 8 Aug 2002)
. . . . . . Re: Date Validation? (Jake Howlett, Fri 9 Aug 2002)
. . . . . . . . Re: Date Validation? (fatima, Tue 27 Aug 2002)
. . Can I use a field to specify required fields? (Armand Tara, Wed 27 Mar 2002)
. . Problem with Rich Edit Applet (Francisco Herrera, Thu 18 Apr 2002)
. . . . Re: Problem with Rich Edit Applet (Jake Howlett, Thu 18 Apr 2002)
. . . . Fix: Problem with Rich Edit Applet (Ian Lycett, Wed 19 Jun 2002)
. . . . . . Re: Fix: Problem with Rich Edit Applet (jenny knight, Wed 28 Feb 2007)
. . . . Re: Problem with Rich Edit Applet (dcS, Wed 15 Jan 2003)
. . Date Validation (James, Tue 1 Oct 2002)
. . . . Re: Date Validation (Stan Rogers, Thu 3 Oct 2002)
. . . . date format (dd/mm/yyyy) (noor, Thu 9 Jan 2003)
. . . . . . Re: date format (dd/mm/yyyy) (dave, Wed 3 Dec 2003)
. . . . . . . . Re: date format (yyyy/mm/dd)validation (nandhakumar, Tue 30 Jan 2007)
. . . . . . . . . . Re: date format (yyyy/mm/dd)validation (Jake Howlett, Tue 30 Jan 2007)
. . . . . . Re: date format (dd/mm/yyyy) (sundar, Fri 3 Jun 2005)
. . . . . . . . Re: date format (dd/mm/yyyy) (lakshmi, Tue 2 Aug 2005)
. . . . . . . . . . Re: date format (yyyy/mm/dd) (Sangeetha, Tue 24 Jul 2007)
. . can't find the .js files (andy heller, Thu 2 Jan 2003)
. . problem doing validation on Notes client (Sally, Thu 8 May 2003)
. . . . Re: problem doing validation on Notes client (Jake Howlett, Mon 12 May 2003)
. . Checkbox (Fredrich, Tue 20 May 2003)
. . Some Suggestions (Charlotte, Tue 30 Sep 2003)
. . Bug in (2.0) (cuschman, Thu 11 Sep 2003)
. . . . Re: Bug in (2.0) ... easy fix ... (cuschman, Thu 11 Sep 2003)
. . . . . . Date Format (yyyy/mm/dd) (Manish, Mon 14 Mar 2005)
. . . . . . . . Re: Date Format (yyyy-mm-dd) (ramesh, Thu 28 Apr 2005)
. . . . . . . . . . Re: Date Format (yyyy-mm-dd) (bhavna, Sat 11 Feb 2006)
. . . . . . . . . . . . Re: Date Format (yyyy-mm-dd) (kaleem, Mon 16 Oct 2006)
. . . . . . . . . . . . . . Re: Date Format (yyyy-mm-dd) (prachi, Tue 9 Jan 2007)
. . . . . . . . . . . . . . Re: Date Format (yyyy-mm-dd) (mika, Thu 31 Jul 2008)
. . . . . . . . . . Re: Date Format (yyyy-mm-dd) (ramesh, Tue 20 Mar 2007)
. . . . . . . . . . Re: Date Format (yyyy-mm-dd) (sarath kumar, Tue 17 Apr 2007)
. . . . . . . . . . Re: Date Format (yyyy-mm-dd) (kiran, Sun 2 Dec 2007)
. . . . . . . . . . Re: Date Format (yyyy-mm-dd) (Hamed, Tue 10 Jun 2008)
. . . . . . . . Re: Date Format (yyyy/mm/dd) (Symon, Wed 8 Nov 2006)
. . . . . . . . Re: Date Format (yyyy/mm/dd) (renuka popli, Wed 25 Jul 2007)
. . . . Number Validation (Simon Walker, Wed 8 Jun 2005)
. . . . . . Re: Number Validation (Jake Howlett, Wed 8 Jun 2005)
. . . . . . . . Re: Number Validation (Simon Walker, Wed 8 Jun 2005)
. . Refresh fields on keyword change (Ian, Fri 5 Mar 2004)
. . . . Re: Refresh fields on keyword change (ronak, Tue 8 Mar 2005)
. . . . . . Re: Refresh fields on keyword change (sunil, Mon 6 Oct 2008)
. . Phone number validation added (Charles Parra, Wed 30 Jun 2004)
. . HTML Password Type Fields (Simone Guest, Tue 24 Aug 2004)
. . . . Re: HTML Password Type Fields (Jake, Wed 25 Aug 2004)
. . . . Re: HTML Password Type Fields (taufeeq, Thu 24 Mar 2005)
. . . . . . Re: HTML Password Type Fields (Aamir, Thu 5 Jan 2006)
. . Validate number of zeros (Jackie, Tue 22 Feb 2005)
. . Form Validator R2.0 - updating array (Yvonne, Wed 23 Feb 2005)
. . . . Re: Form Validator R2.0 - updating array (Jake, Thu 24 Feb 2005)
. . . . Re: Form Validator R2.0 - updating array (henrik, Tue 15 Mar 2005)
. . How to use the nsf file (Yvon, Sun 17 Jul 2005)
. . . . Re: How to use the nsf file (Jake Howlett, Mon 18 Jul 2005)
. . Error message (Evelyn, Thu 14 Sep 2006)
. . . . _getEditAppletData() problem with Sun JVM (Chuck, Wed 3 Oct 2007)

Add your response here:

Name *:
Email:
Protected from spambots!
Remember My Details
Subject *:
Message:
HTML is not allowed and Passthru is disabled!
*=required