Was this helpful?
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.
IN SIMPLE FIELDS
Form Display Mode
Action or Statement
Fill
Read
Update
Query
User moves cursor forward out of the current field to new field. Is the current field validated? 1
Y
N
Y
N
User moves cursor backward out the current field to a new field. Is the current field validated? 1
N
N
N
N
The getform statement references a simple field. Is the field validated?
Y
Y
Y
D
The putform statement references a simple field. Is the field validated?
D
D
D
D
Program performs a validate fieldname against a simple field. Is the field validated?
Y
Y
Y
D
 
ACTIONS NOT DEPENDENT ON FIELD TYPE
Display Mode
Action or Statement
Fill
Read
Update
Query
User presses the menu key or a control/function key mapped to a FRS key. Is the current field validated? 1
N
N
N
N
User presses the menu key or a control/function key mapped to a FRS key. Validation checking is on for that key. Is the current field or table field column validated?
Y
N
Y
D
The program issues an enddisplay. Are simple fields and the visible table field rows validated?
Y
Y
Y
D
The program issues a breakdisplay. Are simple fields and visible table field columns validated?
N
N
N
N
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: 08/14/2024