How Field Validation Works
Validation is a process performed by the FRS, using criteria specified in a form's VIFRED definition, to ensure that data in a field is valid. Validation checks can be performed on all fields on a form or on individual fields. When the validation is performed on a table field, the validation can affect either a single cell in the table field or an entire row. Validation checks can occur when the user moves the cursor out of a field, selects a menu item, presses the menu key, presses a function or control key mapped to an FRS key, or scrolls a table field. They can also occur if the program issues either a validate or validrow statement.
There are three steps to the field validation process:
1. If the field was defined in VIFRED with the mandatory attribute, the FRS verifies that a value is present in the field.
2. If the field has a numeric, date, or money format, the FRS verifies that the data in the field is the correct type.
3. If the field was defined in VIFRED with a validation check, the FRS checks that the field's entry matches the criteria specified.
When the validation is performed on a table field row, all non-hidden and non-derived columns, including display-only columns, are validated.
If the validation check fails at any step in the process, the current operation stops and the Forms Runtime Editor returns the cursor to the beginning of the field that failed the check.
Note: When the validation occurs as a result of a getform, getrow, putform, or putrow statement, the program continues with the following statement even if a field fails the validation check.
There are several methods to specify when validation checks are performed in an application. The set_frs frs statement, using the validate constant, can be used to set global validation defaults for forward tabbing, backward tabbing, menu items, frskeys, and the menu key. You can override the default settings for specific menu items and frskeys with the activate statement (with the menuitem and frskey conditions). Or, you can issue a validate or validrow statement inside an initialize or activate block.
The display mode of the form or table field also affects whether or not a validation occurs.
The following tables describe the effects of form modes on field validations. The tables indicate whether validations are performed; a Y means that all three steps of the validation are performed, an N means that a validation is not performed, and a D indicates that only Step 2 is performed. The numbers after some entries refer to the footnotes following the tables.
4. These are the default validations. You can override these validations with the set_frs or activate statement.
5. You cannot use the set_frs statement to override these validations.
Last modified date: 11/09/2022