Custom Validation

Custom Validation

Validating data at the point of entry can be vital when a value must be within a specific rangelength, or format. This can inform users about the data required within fields and ensure accuracy.

Formulas using functions from our Formula Cheat Sheet make this possible, and if you’re looking for more granular control of alphanumeric text, Regular Expressions (Regex) are also supported.


Standard Validation

The following standard options are available for validating user answers before looking into implementing custom formulas.

PropertyDescriptionWhat it looks like
Required
On almost all field types.

Enforces the user to provide an answer, eliminating the possibility of missing data in key form fields

This property also includes a conditional logic option for when a field becomes required.

Example
If the answer to a safety checklist question is “Failed”, then you can use the conditional logic to make it a requirement that the user submits a photo of the item/asset being inspected.
Date RangeOn Date / Time fields

Allows a minimum and maximum date range to be set, preventing the user from selecting a date outside of it.
Number RangeOn Numeric fields. 

Allows a minimum and maximum number range to be set, preventing the user from selecting a number outside of it.
Answer FormatOn Text fields. 

Choose a common formatting rule to which the value entered conforms.

– Email Address
– Local Phone
– International Phone
– Web Address
– List of Emails

Validation Behaviour

You have full control over how validation happens on every page of your form. The default behavior is “Inline”, but you can change it by selecting a page field in your form and specifying the validation type for that page.

  • Inline
    Validation occurs immediately after the user has entered a value into a field.
  • Page Change
    Validation occurs when the user tries to navigate to another Page.
  • End of Form
    Validation allows the user to leave this page while fields remain invalid, and validation checks are performed only when the entry is to be uploaded.

Custom Validation

The “Custom Validation” property is available on almost every field type. It allows a formula to be defined that checks whether a value is valid according to a business-specific rule or requirement.

If a formula result is TRUE, the value is valid. If FALSE, the value is invalid, and a default or custom validation message will be displayed in the app.

Formulas can be entered directly into the property or using the Formula Builder by clicking the hammer icon.

You can reference the data name of the field to which you are applying the validation without using the VAL() function, i.e., {{field1}} as opposed to VAL(‘field1’). VAL() is generally used in the Dynamic Value property of a field when its current value needs to be referenced to drive its new value.

The Custom Validation property requires a FALSE result to trigger (i.e., this value is FALSE, hence not valid, notify user) and, in turn, display the validation message.

With a FALSE result triggering the validation message, there are three common methods for creating a formula to do this, depending on your preference.

For example, let’s trigger validation if a number is less than or equal to 100. Assuming the data name of the validated field is numeric.

Option 1

Add a formula that checks if the value is what you need.

Example
{{numeric}} > 100

As long as the value entered is above 100, the result is TRUE. As soon as it falls below or equals 100, the result is FALSE, triggering validation.

Option 2

Add a formula that checks if the value is not what you need.

Encase a condition in a NOT() function.

Example
NOT({{numeric}} <= 100)

The condition returns TRUE when the value is less than or equal to 100, and NOT() inverts it to FALSE(), triggering the validation.

Option 3

Add a formula that lets you specify the result of a condition.

Using an IF() function.

Example
IF({{numeric}} <= 100 , FALSE() , TRUE())


When the IF() function’s condition is TRUE, and the value is less than or equal to 100, the IF() function returns FALSE, triggering the validation.


Data Validation

The following examples touch on a few types of data validation.

Range Validation+

Check whether a value falls within a given range.

For example, a number needs to be greater than 100 and less than 200. Validation formulas would look like this:

Example 1
{{dataname}} > 100 AND {{dataname}} < 200
Example 2
NOT({{dataname}} <= 100) AND NOT({{dataname}} >= 200)
Example 3
IF({{dataname}} <= 100, FALSE(), TRUE()) AND IF({{dataname}} >= 200, FALSE(), TRUE())

Length Validation+

Check if a value’s number of characters falls between a set range of values.

For example, a value’s character length needs to be greater than 10 and less than 20. Validation formulas would look like this:

Example 1
STRING-LENGTH({{dataname}}) > 10 AND STRING-LENGTH({{dataname}}) < 20
Example 2
NOT(STRING-LENGTH({{dataname}}) <= 10) AND NOT(STRING-LENGTH({{dataname}}) >= 20)
Example 3
IF(STRING-LENGTH({{dataname}}) <= 10 OR STRING-LENGTH({{dataname}}) >= 20, FALSE(), TRUE())

Format Validation+

Check if a value’s format starts with or contains a set of values.

For examples (1-3), validation formulas would look like this:

A value must not contain special characters (#, %, &).

Example 1
NOT(CONTAINS({{dataname}} , ‘#’) OR CONTAINS({{dataname}} , ‘%’) OR CONTAINS({{dataname}} , ‘&’))
Example 2
IF(CONTAINS({{dataname}} , ‘#’) OR CONTAINS({{dataname}} , ‘%’) OR CONTAINS({{dataname}} , ‘&’) , FALSE() , TRUE())

A value needs to start with the text ‘AB-‘:

Example 1
STARTSWITH({{dataname}} , ‘AB-‘)

A value needs to contain the text ‘@=at’:

Example 1
CONTAINS({{dataname}} , ‘@=at’)

Consistency Validation+

Check if a value needs to be greater or less than another value. For example, a start date needs to be before an end date, and vice versa.

On Date/Time fields, validation formulas would look like:

For the start date.

Example 1
{{startDate}} < {{endDate}}
Example 2
NOT({{startDate}} > {{endDate}})
Example 3
IF({{startDate}} > {{endDate}} , FALSE() , TRUE())

For the end date.

Example 1
{{startEnd}} > {{startDate}}
Example 2
NOT({{endDate}} < {{startDate}})
Example 3
IF({{endDate}} < {{startDate}} , FALSE() , TRUE())

    • Related Articles

    • Validating Answers (Custom Validation)

      TABLE OF CONTENTS Example: Social Security Number Example: Time Example: Multiple Email Addresses When it comes to validating user answers, you have the following standard options: Required - forces the user to provide *something* as an answer ...
    • SQL Form Connectors – Custom SQL

      There are two ways to control the flow of data to your SQL tables using one of our SQL form connectors (SQL Server, MySQL, or PostgreSQL): “Auto Maintain” and “Custom SQL“. In this article, we’ll look at “Custom SQL” and how you can use it in your ...
    • Hiding Content in Custom Templates

      Sometimes, you’d like to show or hide sections of your data template based on the outcome of each Form entry’s answers. For example, you may have an optional section in your Form that is not displayed or filled out, depending on what the app user ...
    • Mapping – Custom Tiles

      To understand the implications and uses of this feature, you’ll first need to understand what map tiles are. Briefly, web maps use a tile server to obtain map tiles for display. The term “map rendering” refers to creating a visual map from raw ...
    • Custom Icon Sets & Styling

      Our platform offers icon customization options from a selection of built-in sets and the capability to upload your custom images as icons. Icon customization can be done at two levels, depending on your account setup. For most accounts, this is done ...