Expressions for form validation

The Form validation group box on the Advanced tab of the Field dialog is for internal (FORMS) validations involving one or more fields.

In the Expression box you type an expression for validation of a numerical field or fields (including barcode fields).

The table below shows the characters that are valid in expressions used to validate fields.

Remember: Unless a field has index 0, you must always specify the index in square brackets. Example: FieldA[5]. For more information, see Field names and indexes.

Char.

Meaning

Examples

Arithmetic operators

+

Plus

=FieldA+FieldB

-

Minus

=FieldA-FieldB

:

Sum of fields from/to

<FieldA[1]:FieldB[5]

*

Multiply

>FieldA*10

/

Divide

=FieldA/2
(If both operands are integers, the result is an integer.)

%

Remainder

=FieldA%100
(Returns the remainder of FieldA / 100.)

Conditional operator

?

Does the field exist?

=?FieldB
(Returns 1 if the field exists, otherwise 0.)

Relational operators

=

Equal to

=100

>

Greater than

>FieldC

<

Less than

<FieldC[3]

>=

Greater than or equal to

FieldA>=FieldB

<=

Less than or equal to

FieldA<=FieldB+FieldC

Logical operators

;

And (between two expressions

FieldA=FieldB+FieldC; FieldA=FieldD

Other characters

( )

Parentheses

(FieldA+FieldB)*FieldC

There are two types of expressions. For more information, click the one that applies to your situation:

Type 1 validates the current field in relation to other fields.

Type 2 validates any numerical field in the form definition.

Note

If the current field is non-numeric, the expression must be type 2 and validate another field, because non-numeric fields cannot be validated by an expression. Furthermore, when you use a semicolon as the AND operator, the expression must always be type 2.

To validate a field containing text, you can also create a table to validate the field or use the Specification box on the Standard tab to specify which characters are allowed or not allowed.

Precision of calculations on values with decimals