How to Add Field Validation

Several different approaches can be used to implement field validation. This section illustrates how to add validation to fields on a form. This approach can be utilized on forms designed to run on the Lotus Notes client (as opposed to a Web browser). Field validation allows you to control and validate the information entered in a field.

Note

An alternative solution for field validation that utilizes the QuerySave event can be found in Chapter 13, "Design Enhancements Using LotusScript."

 

How It Works

A formula is added in the "Input Validation" event for a particular field. The "Input Validation" event is located in the Programmer's pane for most editable fields. Most notably, this event is not available for computed or Rich Text fields. Validation occurs when the document is saved or refreshed. If the resulting field value equates to trUE, then the user can continue with the form. Otherwise, the user must successfully enter or select a value before continuing to the next field.

ImplementationExample 1

To implement this solution, insert a formula that checks the field for validity in the "Input Validation" event of the specific field. This first example ensures that the field contains a non-null value. The user must enter a value in order to continue with the form.

@If(@ThisValue = "";
 @Failure("Please specify a value for the field.");
 @Success);

 

ImplementationExample 2

This second example illustrates how to check a number field for a value. First, the formula checks to see whether the field contains a non-null value. If the field is null, the user receives the first error message to specify a value. If a number has been provided, the formula then verifies that the value is between 1 and 99. If the value is outside this range, then the user receives the invalid number error message.

myValue := FIELDNAME;
@If(myValue = "";
 @Failure("Please specify a value between 1 and 99.");
 @If(myValue < 1 | myValue > 99;
 @Failure("Invalid Value. Specify a number from 1 to 99);
 @Success)
 );

Note

Be sure that the validation formulas are placed in the "Input Validation" event and not the "Input Translation" event. If added to the "Input Translation" event, the error text may be embedded in the field, and the popup error message will not display.


Display an Are You Sure? Warning Message

An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management

Security

Application Deployment and Maintenance

Troubleshooting

Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?



Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net