Skip Navigation

About This Website

CodeStore is all about web development. Mostly with the Lotus Domino server.

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 »

About This Page

Written by Jake Howlett on Tue 23 May 2006

Permalink: Form Validation v3.0b

Skip to the comments or add your own.

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

Recent Comments

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

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
    • Posted on 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
    • Posted on Thu 25 May 2006 03:14 AM

    found on digg today : {Link}

    • avatar
    • Joff
    • Posted on 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
    • Posted on Thu 31 Aug 2006 01:30 PM

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

    • avatar
    • Jamille
    • Posted on Tue 5 Dec 2006 01:06 PM

    Hi Jake,

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

    Thanks again

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

    Hi Jamille,

    You can find it here:

    {Link}

    Jake

    • avatar
    • Mishael
    • Posted on Mon 18 Jun 2007 03:46 AM

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

Add your own response here:

Although your email address isn't required it is protected from spambots if you choose to provide it and not to hide it. My right to remove commercial, irrelevant or posts I just don't like is reserved.

Name *:
E-mail:
Website:
 

Comment *:

HTML is not allowed!