logo

Form Validation v3.0b

As mentioned yesterday I am re-working my old Form Validation database. Here's what v3 looks like now.

It's experimental at the moment, but it works. If you're using the old v2 methods then all you need to do to upgrade is add effects.js, prototype.js and overwrite validation.js with the newer version. There's no need to change anything at the Form level.

Apart form cosmetic changes I think I need to rewrite the whole thing. When I wrote that code all those years ago it was a case of simply making it work and little thought was given to the actual code. It seems nowadays that the way people write JavaScript has changed. Everything gone all Object Orientated. In the current code validation is a case of:

if ( validateRequiredFields( f, a ) ){

Now it's more normal to expect something like:

if ( Form.validate() ){

Whereas before the settings and properties were global variables they are now properties of the Object we define to handle the validation functions.

While I managed to do this style of coding in the code for the Name Picker demo I have to admit I don't fully understand it all the time. Before I rewrite the validation code I think I might stick my head in my JavaScript manual. Bear with me. If you want the validation database as it stands now, let me know and I'll mail it over.

Comments

  1. I think I may have mentioned here once before (or maybe it was on my blog), an indepth analysis of Scriptaculous will give you some ideas and patterns for good OO javascript. It's very much a reverse engineering approach, but it is a current up to date implementation of OO Javascript. I used it as a template when I took some older style JS widgets OO to make them easier to implement in batches on a form.

    {Link}

    • avatar
    • Jake
    • Tue 23 May 2006 08:05 AM

    Thanks Jerry. Good idea. Reverse engineering is how I've always "learnt" things in the past. In this case though I don't know if I'll ever get to the point where I understand what and why I'm doing. I'll do a bit of background reading first me thinks.

  2. Hi Jake, Can you pls mail me the new Form Validation Example. Thanks a lot

  3. Any example for fields thats not mandatory but if user entered anything, it will check if it's numeric? It would be good if the validation can check for the number of checkbox if required.

  4. Would it not be better to list all the required fields at the top and then just highlight each field in red? If the form is really long the user might not know that it hadn't been submitted, as the error could be out of the screen.

    I normally show all errors in red at the top of the screen, show a messagebox listing all errors, and also set the focus to the first mandatory field.

    • avatar
    • YoGi
    • Thu 25 May 2006 03:14 AM

    found on digg today : {Link}

    • avatar
    • Joff
    • Thu 13 Jul 2006 11:33 AM

    I would like a copy of the db as it stands now, thanks! This will look very good for an appI amrevising...

    • avatar
    • Adam
    • Thu 31 Aug 2006 01:30 PM

    Hi Jake, could you email me the Validation example database? thanks!

  5. Hi Jake,

    Looks great, if you get a chance I would love to take a look at the code.

    Thanks again

    • avatar
    • Jake Howlett
    • Tue 5 Dec 2006 04:17 PM

    Hi Jamille,

    You can find it here:

    {Link}

    Jake

  6. I am trying to validate a url in my form using javascript but I couldn't! Any help?

  7. Jake- great stuff. I would love a copy of the current nsf if you might. Thanks.

    • avatar
    • Jake Howlett
    • Sat 3 Jul 2010 12:50 AM

    Hi Tom. This code is in the "DEXT" database, which you can download from the Sandbox tab above.

    • avatar
    • Louis Piano
    • Mon 21 Mar 2011 12:28 PM

    Jake,

    How would you pass a test function to determine that at least three check-boxes have been selected?

    • avatar
    • Jake Howlett
    • Mon 21 Mar 2011 03:13 PM

    Hi Louis. Take a look at the "custom option" in the demo:

    http://www.codestore.net/apps/validation30.nsf/contact?OpenForm

    You could write your own little function to count the number of selected checkboxes and return true/false.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 23 May 2006

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content