Set a validation rule using the rule builder

Language: English

Validation rules restrict what a user is allowed to input in a field. If a user’s input violates the validation rule, the user won’t be allowed to save the record.

In this tutorial, we will add a simple validation rule to form collecting data about primary school students, specifically to the age field.

Step 1: Add a new form

  1. From the database page, click “Add Form”
  2. Enter “Student registration” as the Form Name

Add the name field

  1. Click “Add a field”
  2. From the list of field types, click “Text”
  3. Enter “Name” as the label
  4. Check “Key” in settings

Add the age field

  1. Move your cursor below the first field and click the “+” button
  2. From the list of field types, click “Quantity”
  3. Enter “Age” as the label
  4. Check “Required” in settings
  5. Check “Set validation rules”
  1. Scroll down to the “Validation Rules” section
  2. Where it says “Count as valid if”, change “Any” to “All”
  3. In the first row of the rules editor, change the predicate from “is” to “is greater than”, and set the value to “3”
  4. Click the “Add” button to add another row in the rules editor
  5. In the second row, change the predicate from “is” to “is less than” and set the value to “12”
  1. Enter a message in the “Validation error message” text box below the rules editor, for example “Age must be greater than 3 and less than 12”. The message is optional and limited to 1,024 characters. If you leave it blank, ActivityInfo shows a default message derived from the rules defined. The error message is translated in the same way as a field’s label and description.
Validation error message
Validation error message
  1. Click “Done”

  2. Click “Save” to save the form

Step 2: Test the data entry form

  1. From the Table View, click “Add Record”
  2. In the name field, enter “Oliver Twist”
  3. In the age field, enter “20”
  4. Click “Save record”

Because “20” violates the validation rule, ActivityInfo will not allow you to save the record. An error message will be displayed below the field:

Validation error message in the data entry form
Validation error message in the data entry form
Validation error message in the interactive table
Validation error message in the interactive table

Change the value to 6 and you then you can save the record.

Next item
Validation rules