Input Validation

Domino developers have long used the Notes input-validation field property to validate their field data. JavaScript offers yet another method to check field data for validation.

The following example uses JavaScript for the form's onChange event, and the code is called from the JS Header . Why do it this way? Have you ever encountered a validation error and not known what field it is for? This can cause a developer much wasted time and effort searching and screening each field on the form to debug it. By placing your code in one central location, you can quickly and easily find all your input validations. This also allows you to program your error messages so that you can explicitly name the field throwing the exception.

Here's an input-validation JavaScript function placed in the JS Header on a problem report form in Domino:

//The Input Validation Function for all required fields on a form. 
function validate(){
var validatemsg;
var validateflag;
validateflag = 'false';

 if(document.forms[0].Caller.value == ''){
 validatemsg='CALLER FIELD ERROR: Please select a caller name in the caller
field on this form!';
 if(document.forms[0].Body.value == '') {
 validatemsg='BODY FIELD ERROR: Please enter details for the problem that was
 if(validateflag == 'true'){
 if(validateflag == 'false'){

This validation code steps through each field on a problem report form and checks to make sure that the required field data is filled in. If the function encounters a field in which the data is not filled in, the user is prompted by an error message indicating the field name, the problem, and the user returned to the appropriate field to correct their error. When the field passes the validation check and the validateflag variable equals false (there are no errors), the document is saved. Figure 16.18 shows what this code looks like inside the JS Header of the Designer.

Figure 16.18. The validation code in the JS Header of the Designer.


To call the validate() function, simply place the function call in an action button or event on the form. Figure 16.19 shows a Save and Close action button along with its onClick function call in the Programmer's pane.

Figure 16.19. The Save and Close action buttons in the JS Header of the Designer.


You can also call the function in the form's onSubmit event. Either way, the fields are validated using the validate() JavaScript function.

Part I. Introduction to Release 6

Whats New in Release 6?

The Release 6 Object Store

The Integrated Development Environment

Part II. Foundations of Application Design

Forms Design

Advanced Form Design

Designing Views

Using Shared Resources in Domino Applications

Using the Page Designer

Creating Outlines

Adding Framesets to Domino Applications

Automating Your Application with Agents

Part III. Programming Domino Applications

Using the Formula Language

Real-World Examples Using the Formula Language

Writing LotusScript for Domino Applications

Real-World LotusScript Examples

Writing JavaScript for Domino Applications

Real-World JavaScript Examples

Writing Java for Domino Applications

Real-World Java Examples

Enhancing Domino Applications for the Web

Part IV. Advanced Design Topics

Accessing Data with XML

Accessing Data with DECS and DCRs

Security and Domino Applications

Creating Workflow Applications

Analyzing Domino Applications

Part V. Appendices

Appendix A. HTML Reference

Appendix B. Domino URL Reference

Lotus Notes and Domino 6 Development
Lotus Notes and Domino 6 Development (2nd Edition)
ISBN: 0672325020
EAN: 2147483647
Year: 2005
Pages: 288 © 2008-2020.
If you may any questions please contact us: