Next: The Form Driver, Previous: Form Windows, Up: Forms Library [Contents][Index]
By default, a field will accept any data input by the user. It is possible to attach validation to the field. Then any attempt by the user to leave the field while it contains data that doesn’t match the validation type will fail.. Some validation types also have a character-validity check for each type a character is entered in the field.
Validation can be attached by using the set-field-type!
procedure and queried with the field-type
procedure.
The form driver validates the data in a field only when data is entered
by the end-user. Validation does not occur when the application
program changes the field value with set-field-buffer!
.
The validation types are as follows.
TYPE_ALPHA
This field type accepts alphabetic data; no blanks, no digits, no special characters. It takes a width argument that sets a minimum width of the data. The user has to enter at least that number of characters be fore he can leave the field. Typically you’ll want to set this to the field width. If it’s greater than the field width, the validation check will always fail. A minimum width of zero makes field completion optional.
(set-field-type! field TYPE_ALPHA width)
TYPE_ALNUM
This field type accepts alphabetic data and digits. No blanks, no special characters. It also has a width argument.
(set-field-type! field TYPE_ALPHA width)
TYPE_ENUM
This type allows you to restrict a field’s values to be among a specified set of string values (for example, the two-letter postal codes for US states). It takes as input a list of strings. It can be set up as either case sensitive or case insensitive. When the user exits, the validation procedure tries to complete the data in the buffer to a valid entry. If a complete choice string has been entered, it is, of course, valid. But it is also possible to enter a prefix of a valid string and have it completed for you.
By default, if you enter such a prefix and it matches more than on value in the string list, the prefix will be completed to the first matching value. If the check-unique option is chosen, the prefix match must be unique to be valid.
(set-field-type! field TYPE_ENUM valuelist checkcase checkunique)
TYPE_INTEGER
Valid characters consist of an optional leading minus and digits. A range check is performed on exit. If the range maximum is less than or equal to the minimum, the range is ignored.
(set-field-type! field TYPE_INTEGER zero-padding min max)
If the value passes its range check, it is padded with as many leading zero digits as necessary to meet the padding requirement.
TYPE_NUMERIC
This accepts a decimal number.
(set-field-type! field TYPE_NUMERIC digits-of-precision min max)
Valid characters consist of a leading minus and digits, possibly including a decimate point. The range check is performed on exit.
If the value passes its range check, it is padded with as many trailing zero digits as necessary to meet the padding argument.
TYPE_REGEXP
This field type accepts a regular expression, and thus can be used to perform other types of range checks.
Next: The Form Driver, Previous: Form Windows, Up: Forms Library [Contents][Index]