Error Reporting Ideas

By now we're probably all familiar with using JavaScript to validate data submitted via a web form. It's something most of us do on a day-to-day basis. How many of us stop to think how fool-proof a method this is though? After all, it's easy for a user with some knowledge of JavaScript to completely bypass the validation.

If it's "mission critical" that the data is valid then there's no real substitute for server-side validation. The idea being that you submit the form only for it to be displayed again, with your original values in place and any errors highlighted. You correct the errors and try again until everything is ok and the form saves. Personally, I prefer either this method alone or a combination of the two. There are a few forms where I've done this using PHP, but what about doing some server-side validation in Domino?

It's been a few months since I had this idea and made my first failed attempt. All this recent talk of errors has got me thinking about it again. What I wanted to do was a simple validation, using some @Functions, when the form is submitted. If it fails then the form is re-displayed with the submitted values and the errors listed. My idea was to do this in the WebQuerySave event. If it fails then set a SaveOptions field to "0" and the document won't save.

What I couldn't do was stop the document from saving when there were errors. Today or tomorrow I will try again and see how I get on. In the mean time I am open to suggestion. Any of you know a way to do this? Simply!


  1. You should set the SaveOptions field's default value to "0" and if it passes validation then set to "1". I've tried this before and ran into the same problem.

    • avatar
    • David
    • Tue 25 May 2004 08:29

    How about doing it all in JSP and building a Domino forms & view translator while you are at it?

    There is the 'Custom Tage Conversion Kit' available that will convert these to JSP but it needs a lot of work to turn it into a forms generator package.

    If you build it we will come buy it.

    (That's not a contract by the way!)

  2. Set a validation field (yes/no).

    Save the document whether it validates or not.

    Put an @If in the $$Return - Yes = "Thank You" page - No = "re-open document in Edit mode"

    Bit of a hack I'm afraid

    • avatar
    • Digger
    • Tue 25 May 2004 09:40

    Some interesting things about validating forms at {Link}

    Also have a look at other articles.

  3. I save all submissions regardless if it passes validation or not. I set a flag only when the document passes the validation.

    To prevent creating a lot of deletion stubs, any documents that the user has abandoned (failed validation and quit) end up in a recycle view after a certain period of time. When new documents are to be generated, I first look in this view if I can use any recycled docs.

    This is used in an intranet application and may not work so well for an internet app.

    • avatar
    • Jake
    • Tue 25 May 2004 10:11 AM

    Brad. I'll give that a go. Thanks.

    David. I said simple ;o)

    Digger. Thanks for the link. Going to have a read now.

    Andy & Mark. I really want this approach not to save unvalidated posts at all.

    • avatar
    • Doug Cohen
    • Tue 25 May 2004 10:51 AM

    I have accomplished this in two different ways....

    (1) in the WebQuerySave area, write out a variable that contains all of the information that you want the user to see when the validation fails. Once you do that, put it in @Failure(). The only issue here is that on a Domino 6 box, the fields will clear themselves out unless you adjust the server's Notes.ini file.

    (2) actually call a WebQuerySave agent, written in LotusScript, as you can set the SaveOptions field to 0 and it will hold. At this point, use a Print statement to display all of the information you want the user to see.

    • avatar
    • Doug Cohen
    • Tue 25 May 2004 10:57 AM

    Let me take that back... item (1) did not work for me when I tried it, so I stuck with (2).

    • avatar
    • TimCrannigan
    • Tue 25 May 2004 11:43 AM

    We had this problem plus the need for users to design their own forms without HTML knowledge.

    Thus we designed a web forms database where users (who have access) can design headers, up to 40 fields - complete with custom validation - various actions on save, daisy chaining forms, etc. Anyone interested in having this database is welcome to a copy (though it might need tweaking to remove some of our company stuff).

    And validation is done in the webquerysave, with javascript history.go(-1) if an error is found.

  4. Oh, and...

    I forgot, we did initially have total javascript validation, but it got too complex, particularly with browser differences handling of different field types, so switching to lotusscript took a lot of form failures away - and 10 x easier to maintain.

  5. Jake, I have done this with @Functions.

    I have the forms "SaveOptions" set to 0.

    I have a CFD field called "FieldValidation" that has a hide/when of FieldValidation="".

    Finally, I have a submit button that does the work setting this CFD with information and links to the fields that are not valid.

    It seems to work fine and is easy to setup. I have done this mainly with @Mailsends instead of form saves. But I'm sure it could be used to save the form as well. If you are interested, I can forward on a small db with a form in it. Just drop me a note and I'll put one together.

    • avatar
    • Jake
    • Tue 25 May 2004 12:40 PM

    Thanks Lance. I'll let you know if I need it. It sounds like you've done something similar to what I ended up. The only trouble seems to be telling a document *not* to save. Maybe it's to do with the order of the fields. Maybe SaveOptions has to tbe last field? Hmmm...

  6. I've done it without having to use SaveOptions fields.

    I usually have a field at the top of the document called DocErrsDisp which is computed for display and hidden if DocErrorsDisp=""

    In my submit button, i do my validation. If I find an error, I append the error to the field. For example, if the firstname field shouldn't be empty:

    FIELD DocErrorsDisp := @If(@Trim(Firstname) = "";

    DocErrorsDisp + "The \"First Name\" field is required.<BR>";



    At the end of the button, test for an error:

    @If(DocErrorsDisp !=""; @Return(""); "");

    if everything is okay, attempt to save which will run a webquerysave agent:


    REM {If errors did occur, the agent will update the DocErrorsDisp field so stay in edit mode and display the error message};

    @If(DocErrorsDisp = ""; @Command([FileCloseWindow]); @Return(""))

  7. Jake,

    I have also accomplished field validation with only @Functions in the web form's Submit button. The button formula does all the work, and when it detects an error with one of the entry fields, it sets two CFD fields; one that says an error occurred, and a second one that is associated with the specific field that error'ed, and is used to provide helpful feedback to the user. This second field is Hidden when its contents are empty.

    Then the last part of the Submit button checks the global error CRD field, and either opens the required URL, or returns control to the form.

    @If( QueryError = "NO" ;

    @URLOpen( blah blah blah);

    "" )

    This form is a form used to perform a field based full text search in a database.

    • avatar
    • David
    • Tue 25 May 2004 03:55 PM

    I know you said simple but you can't sell simple.

    I'm talking of a product with a market...all of these UK local government & central government departments using Domino and needing to produce cross-browser compatible and highly accessible forms to meet central government targets? But then I've been wrong on these things before.

    • avatar
    • mcat
    • Wed 26 May 2004 02:45 AM

    Here's another 'simple' approach, no agents, just @formulae.

    Create a form.

    Add a computed field errors to the form that computes to "".

    Add your editable input fields to the form.

    Use the following input validation formula in the fields you want to check:

    FIELD errors := @trim( errors : @if( myfield="";"Myfield is empty";"") ); @true;

    On the bottom of the form, add an (hidden) editable field saveoptions with a default value

    of "0" and the following input validation:

    FIELD saveoptions := @if( Errors=""; "1"; "0"); @true;

    Add an action button with @command([FileSave]).

    Done :-)

    • avatar
    • Kurt Meyer
    • Wed 26 May 2004 03:52 PM

    Check out the article "Web UI Techniques Your Users Will Love - Better, More Helpful Validation Error Messages," by Edward Castelli in the July/August 2002 issue of The View.

  8. Like others above I check validation with formula under a submit button. I use SaveOptions defaulted to 0. I append values to a hidden field for each field that fails. If everything passes I set save options to 1, save then open a success form. At failure I refresh. I have hide-whens that display an icon next to each field that requires user intervention. I also have a $$Return field that contains just the URL for the homepage. With SaveOptions and $$Return I have seemed to have stopped ?CreateDocument from creating blank documents and re-direct anyone who tries it, of course this could be a "Happier" message then just a re-direct to a main page.

Your Comments


About This Page

Written by Jake Howlett on Tue 25 May 2004

Share This Page

# ( ) '


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 »

More Content