Valid property

TextField.Valid — Logical

Special value available in formulas:

Item

TextField

The field this property is part of, enabling multiple checked items in the app designer to share the same formula and be updated all at once.

Consider the fields Field1 and Field2, which should only be considered to be valid if their values are greater than 4. Without using the Item value, the Valid property of Field1 would need to use the formula Field1 > 4Field1 > 4 and the Valid property of Field2 would need to use the formula Field2 > 4Field2 > 4.

Using Item, both formulas can read Item > 4Item > 4. This is useful if you have many fields and you want to be able to update their formulas all at once. To do so, click their check boxes in Calcapp Creator and make sure that a checked field is selected. Then, when you update a formula for one checked field, you update all the other checked fields too, which is a great timesaver.

Use Item in exactly the same way you'd use the regular name. Field1.VisibleField1,Visible and Item.VisibleItem,Visible are equivalent, for instance.

Whether the field is valid. The value of an invalid field is shown in red (unless a different warning color has been set). Below the field, a validation message is shown. Customize it through the ValidationMessage property.

To make a field required, use this property in conjunction with the NextScreenAvailable property of screens (preventing users from moving on to the next screen) and the Enabled property of buttons (preventing users from pressing a button). See below for more information.

Writing formulas determining if a field is valid

To determine if a field is valid, you must write a formula and associate it with this property. This formula must return TRUE if the field is valid and FALSE otherwise.

This formula only considers values consisting of three characters or more to be valid:

LEN(TextField1) >= 3LEN(TextField1) >= 3

We suggest that you consider blank field values to be valid. The alternative is for your users to be greeted by forms with validation messages already shown, which does not look inviting.

To consider blank values valid, use the ISBLANK function. Here's the formula above rewritten to accept blank values:

ISBLANK(TextField1) || LEN(TextField1) >= 3ISBLANK(TextField1) || LEN(TextField1) >= 3

(|| should be read as "or.")

Useful functions when writing Valid formulas

Here is a list of useful functions that can be used when writing Valid formulas (see below for examples):

Determining if a field is valid from a formula

On its own, the Valid property only shows a validation message and displays the field value in a different color if the field fails validation. Users are not prevented from moving on to a different screen or from pressing buttons, nor are any calculations inhibited.

Enable these features by accessing whether a field is valid from other formulas. For example, associate the following formula with the Value property of Field2 to prevent it from calculating a value unless Field1 is valid:

IF(Field1.Valid, Field1 * 100)IF(Field1,Valid; Field1 * 100)

If blank values are considered valid (which we recommend), you also need to use ISDEFINED to make sure that a value has been entered:

IF(ISDEFINED(Field1) && Field1.Valid, Field1 * 100)IF(ISDEFINED(Field1) && Field1,Valid; Field1 * 100)

(&& should be read as "and.")

To prevent a user from moving to the next screen, unless both Field1 and Field2 are valid and have defined values, associate a formula like the following with the NextScreenAvailable property of a form screen:

ISDEFINED(Field1) && Field1.Valid && ISDEFINED(Field2) && Field2.ValidISDEFINED(Field1) && Field1,Valid && ISDEFINED(Field2) && Field2,Valid

To prevent a user from pressing a button unless all fields of the Field1:Field5Field1:Field5 range are valid and have defined values, associate a formula like the following with the Enabled property of a button:

AND(ISDEFINED(Field1:Field5) && (Field1:Field5).Valid)AND(ISDEFINED(Field1:Field5) && (Field1:Field5),Valid)

The Field1:Field5Field1:Field5 range includes Field1 and Field5, as well as all fields appearing between them. (Field1:Field5).Valid(Field1:Field5),Valid returns a logical array like { TRUE, FALSE, TRUE, TRUE, FALSE }{ TRUE; FALSE; TRUE; TRUE; FALSE }, where each individual element indicates whether the corresponding field is valid.

ISDEFINED(Field1:Field5)ISDEFINED(Field1:Field5) also returns a logical array, where each individual element indicates whether the corresponding field value is defined (not blank). When && is applied to two arrays, a single logical array is returned, where each individual element is only TRUE if the elements at the same position in the two arrays are both TRUE. The net effect is that an array is returned, where each individual element indicates whether the corresponding field is both valid and has a defined value.

Finally, AND is applied to the resulting array and only returns TRUE if all elements of it are TRUE. The end result is that the formula only returns TRUE if all fields of the Field1:Field5Field1:Field5 range have defined values and are valid.

Examples

LEN(TextField1) >= 3LEN(TextField1) >= 3

Considers a text field to be valid only if the number of characters appearing in its value is greater than or equal to 3.

ISBLANK(TextField1) || LEN(TextField1) >= 3ISBLANK(TextField1) || LEN(TextField1) >= 3

Considers a text field to be valid only if the number of characters appearing in its value is greater than or equal to 3, or if it is blank. We recommend that blank values are considered valid, so as to not have forms warn users of erroneous values before any values have been entered.

ISBLANK(EmailAddress) || ISEMAIL(EmailAddress)ISBLANK(EmailAddress) || ISEMAIL(EmailAddress)

Considers a text field to be valid only if its value is probably an email address, or if it is blank.

ISBLANK(TextField1) || CONTAINS(TextField1, "+")ISBLANK(TextField1) || CONTAINS(TextField1; "+")

Considers a text field to be valid only if its value contains the "+" symbol, or if it is blank.

ISBLANK(TextField1) || REGEXMATCH(TextField1, "^\w+\s+\w+$")ISBLANK(TextField1) || REGEXMATCH(TextField1; "^\w+\s+\w+$")

Considers a text field to be valid only if its value consists of two words, separated by whitespace (like one or several space characters), or if it is blank.

ISBLANK(DateTimeField1) || (DateTimeField1 <= NOW())ISBLANK(DateTimeField1) || (DateTimeField1 <= NOW())

Considers a date and time field to be valid only if its value represents a date that is not in the future, or if it is blank.

IF(ISDEFINED(Field1) && Field1.Valid, Field1 * 100)IF(ISDEFINED(Field1) && Field1,Valid; Field1 * 100)

This formula is associated with the Value property of a number field. A value is only calculated if Field1 has a defined value and is valid. Otherwise, a blank value is produced.

ISDEFINED(Field1) && Field1.Valid && ISDEFINED(Field2) && Field2.ValidISDEFINED(Field1) && Field1,Valid && ISDEFINED(Field2) && Field2,Valid

This formula is associated with the NextScreenAvailable property of a screen. The user is only permitted to proceed to the next screen if Field1 and Field2 both have defined values and are considered valid.

AND(ISDEFINED(Field1:Field5) && (Field1:Field5).Valid)AND(ISDEFINED(Field1:Field5) && (Field1:Field5),Valid)

This formula is associated with the Enabled property of a button. The user is only permitted to press the button if all fields of the Field1:Field5Field1:Field5 range have defined values and are considered valid. The Field1:Field5Field1:Field5 range includes Field1, Field5 and all fields that appear between them.