Manage Learn to apply best practices and optimize your operations.

Friendlier Web Validation

You can validate forms on the web using Notes @Formula language in field validation formula or Javascript in field events or the form onSubmit event.

Using individual field validation checks on the web may discourage users because on submission they only get the failure message from the first field to fail its validation, they may have to make repeated changes and submit a form several times before they get it all right. Repeated failed submissions also involve unnecessary network and server traffic and can be slow.

Javascript validation is better in that it all happens at the client and can be made to present all validation failure messages at once if done via the form onSubmit event. However Javascript adds to the size of the web form, is not standard on all browsers and can be difficult to debug, even more so than Notes formula language!

There is a 'third way' that uses @Formula validation but presents all failure messages at once and displays them attractively too! You can do it all in one field but I prefer to use two.

Add a hidden, computed-for-display field at the top of the form and call it 'ValidationMsg', it can be a shared field if you prefer. The contents of the field should be something like:

"Your document can't be saved"
+ "Sorry

+ "Click go back"
+ " then add the missing details and re-submit.

+ "Click here if you want to abandon your edits"

In the last line 'db' is the name of another computed-for-display field above the 'ValidationMsg' field in the form. 'db' should evaluate to a URL suitable for users to 'jump back into' the web site if they give up their submission, I just re-open the database with the formula:

"/"+@ReplaceSubstring(@Subset(@DbName;-1);"\":" ";"/":"+")+"/"

This 'ValidationMsg' field can be used with validation formula in each field simply by adding the field name to the end of your @Failure string ... but if you want to show all validation failures together, remove validation formula from all editable fields in the form and add another field at the bottom of the form, make it a hidden, editable field and call it 'ValidationCheck'.

This 'ValidationCheck' field is where all the validation happens so you might need lots of @Formula language! The example below does two things really. First, it gets rid of some editable fields used in the form but which don't need to be saved. Second, it selectively adds failure messages to an initial string (x). If the final message (err) is the same as it was at the beginning (if err = x), then we know there are no validation failures and the submission can succeed. If there are errors we add the ValidationMsg text to our error messages, along with some HTML to make it look nice and present it all to the user. The 'ValidationCheck' field Input Validation event might contain a formula like this:

FIELD Bannerweeks:=@DeleteField;
FIELD Bannerdays:=@DeleteField;
FIELD Query_String:=@DeleteField;
FIELD FileQuotaCheck:=@DeleteField;
FIELD PWeb:=@If(PWeb="";@DeleteField;Pweb);
FIELD Phone:=@If(Phone="";@DeleteField;Phone);


x:="You need to enter


    @If(namereq & !(@Length(Name)>7 & @Contains(Name;" "));"

  • contributor's full name
  • ";"")+
    @If(namereq & !(@ValidateInternetAddress([Address821];Email)="" | Phone!="");
  • a valid email address ("+
    @ValidateInternetAddress([Address821];Email)+") or phone number
  • ";"")+
    @If(@Length(Subject)>7; ""; "
  • a longer subject
  • ")+
  • more text
  • ")+
  • just one attached file per message
  • ";"")+
  • your attached file is too big ("+@Text(files)+"K)
  • ";"");

    @If(err=x; @Success;

" "+ValidationMsg+"")

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...