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.
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.
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);
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) );
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
Reference Library Applications
Design Enhancements Using LotusScript
Design Enhancements Using Formula Language
Miscellaneous Enhancements and Tips for Domino Databases
Application Deployment and Maintenance
Appendix A. Online Project Files and Sample Applications
Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?