In previous versions of Domino, developers often had to code two different submit buttons, one for the Notes client and the other for the web browser clients. The web browser button typically used JavaScript to validate the form. The Notes client button would use the formula language. Added enhancements to Domino 6 make it possible to have a common JavaScript library for form validation that can be shared by all your databases and used by both the Notes clients and the web browsers. This tip will show you how to use JavaScript libraries to have a common set of validation routines for both Notes and browser clients.

Click here to see a demonstration of this tip!

To learn more about the new features of Notes Domino 6 check out TLCC's highly acclaimed Notes Domino 6 Application Development Update course!!!

This comprehensive course will make you a Release 6 expert in a mere 2 1/2 days. Easy, convenient and cost-effective, it will thoroughly prepare you for the Notes Domino 6 Application Development Update Exam required to achieve Notes Domino 6 CLP status.

Forget stiff or boring simulations. Along with clearly showing how to use the new Notes Domino 6 development features, TLCC's Notes Domino 6 Application Development Update course offers extensive activities and demonstrations done right in Domino Designer.

You will learn to lock documents and design elements, debug code on a remote server, and save disk space with single copy templates. Get hands-on experience using the new design elements like layers, style sheets, HTML files, JavaScript libraries, and more. Learn how to enable the new in-view document editing feature and the embedded editor feature. Learn and use the many new and enhanced @functions and @commands. Program the new LotusScript/Java objects to work with rich text elements like tables, sections and doclinks. Connect to relational databases using Data Connection Resources, plus much more! As always, you can learn at your own pace, at your own place with TLCC.

TLCC's Notes Domino 6 Application Development Update course - it’s the ideal way to learn Release 6, prepare for the update exam, and quickly become certified as a Notes Domino 6 CLP.

Click here to see customer comments on this course!


Click here for more information on TLCC's Notes Domino 6 Application Development Update course.



Tip Explanation- JavaScript Validation

Your application may need to support both browser users and Notes users. If this is the case, it is much easier to create and maintain a single set of validation functions which supports both types of clients. Typically for web browsers the validation would be done in a button via JavaScript. If the validation is successful then the submit() method would be used to actually submit the form to the server. However, the submit() method does not work in the Notes client (either version 5 or 6.) However, the onSubmit event does work for the Notes client. Use the following steps to have one set of JavaScript validation functions for both the web and Notes clients.

1. Use a "submit" button with @commands

Instead of running JavaScript in the [Submit] button, use the Notes Formula language equivalent to submit the form.


Make sure the database's property is set "Use JavaScript when generating pages."


2. Add code to the onSubmit event

Add code to the onSubmit form event. This code should call the validation function and pass the field name as an argument. If the validation function returns true, indicating a validation failure, a false is returned to the onSubmit event and the form submit is cancelled. Otherwise, if the onSubmit event returns true the form is submitted and saved.


3. Add the validation function(s) to the JavaScript Header

Below is the code in the JavaScript Header to do a simple validation (check for a null value.) You can add unique functions to handle phone numbers, credit cards, etc. depending on your needs.



An alternative to adding the code to the JavaScript Header for Domino 6 servers is to use a JavaScript library. The library can be located in any database in the server. This allows you to have one set of validation functions for all your applications. The image below shows the JSValidations script library being imported into the JS Header event of the form.