Validation is used to test entered data against a set of rules in order to ensure that the data in the system is kept clean and logical. The validation settings for any field can be found by looking at the properties of the field in the form designer.
Setting a field to Mandatory will require that the field has data in it before the record can be saved.
In this example both the First and Last name are set as Mandatory fields.
Pressing the Save button results in the following message:
Validation Formulas provide a similar function to setting a field to mandatory but allow for additional options and more flexible logic.
There are two additional variables available when working with Validation Formulas, those are $thisColumn and $thisValue. As the names suggests these variables retrieve their own column name and value name, this is helpful in allowing you to setup multiple fields using the exact same formula.
Using Validation Formula we will now enforce this rule
- Neither the First nor Last Name should contain have a number
The following formula has been applied to both the First Name and Last Name validation rules.
Here is the input data:
When trying to save the record the follow error appears:
The validation rule has worked however the error returned could be friendlier. The Validation formula allows the configurator to specify the message that is returned by simply returning the value in the formula. Here is an updated formula that will return a custom error message.
Using the same data as above the error message is now more clearly indicating the validation issue.
Further Validation Formulas
The form from above has been expanded further and more validation rules are required to ensure the integrity and cleanliness of data being passed in.
Here are the new rules that need to be implemented:
- If user has a driver’s license then then must provide the date they got their license
- In the case that a user does have a driver’s license, the date that a user got their license must be before today’s date
The field names for the new fields are: [Has Drivers License] and [Date of Drivers License]
Condition 1 is indicating that the [Date of Drivers License] field is only mandatory in a specific case. This can be achieved with the following formula:
Inputting this data:
Results in this message:
Meeting Condition 2 is a potentially a simple addition to the formula something like this:
However the message returned would not properly reflect the validation rule that might fail. This formula will provide a custom message based on the failed validation rule.
NOTE: Returning TRUE or NULL will result in successful validation. Returning FALSE or a string will result in failed validation.
Validation tags are a way of control non-Save events through validation rules. A tag is required to be on a least 1 field and at least 1 button in order to be effective.
In previous examples validation could only prevent the record from Saving, however in this situation we have a button that will trigger an email, however we don’t want the button to be able to send an email until the Email Address field has been filled in.
On the Email Address field enter a custom validation tag – the name can be anything, it just has to match the tag placed on the button.
On the button properties ensure that Causes Validation is set to yes and then enter the tag that matches the tag placed on the field.
It is possible to place the same tags on multiple fields
With no data entered the Send Email button will now only work when the email address field has some data entered.
Validation Tags with Validation Formula
Building off of the email example it is worth adding validation to ensure that the Email Address is in a valid format. This includes the following:
- There is an “@” symbol
- At some point after the “@” symbol and before the end of the input there will be a full stop (“.”)
Field Validation settings: