Fields - validation


field_id, [”heading”], type & size [[dim1 [, dim2 [, dim3 [, dim4]]]]] \
[/logical] [,”format” [, flags [, “validation”]]]

Numeric input data is always automatically validated. The value entered must fall within the range covered by the field type and size, and must conform to the logical type and format, if any. Characters that are obviously incorrect (such as the letters a-z) cannot be input into textboxes linked to numeric fields.

In addition, it is possible to attach a validation list to a field of any type, further defining the data that may be input. This is the validation part of the field’s specification.

A validation list must be in quotes. It may consist of individual values, ranges of values or a combination of both. The items in the list are separated by commas, while hyphens are used to indicate a range.

In order to validate no input as a valid data entry, include two consecutive commas in the validation list.

Alphanumeric data is validated by comparing the input text, firstly for equality with single items in the validation list, and then on a greater-than or less-than basis with the ranges in the list. Although input data is padded with spaces to fill the length of a field, these are ignored for comparison purposes. Therefore care must be exercised with alphanumeric validation lists. If a 2-byte field is to begin with a letter in the range A-M, it is not sufficient to validate the field with A-M. This would cause MB to be invalid. The correct specification would be AA-MZ.


Assigning or retrieving validation at run time

A field ’s validation list may be assigned in a program by the command:

field_id->valid = text_expression

The form field_id->valid can also be used to retrieve a field’s validation list.

NOTES

  • A validation list applies only to input into a field. Assignment to the field is not limited by a validation list; any data valid for the field type and size may be assigned to it.

  • Textbox functions are the recommended method of data validation. See the textbox validate = clause under Textbox events and functions.


EXAMPLES

  1. Alphanumeric fields

    ,,y,n
    MR,MRS,MISS,MS,DR,SIR
    ,,A-M,X,Y,Z
    
  2. Numeric fields

    0-100
    ,,0,100-999
    11-19,21-29,31-39
    

RELATED TOPICS

Data fields

Data validation