Adding validation to your form's fields can greatly improve the accuracy of the data being collected. It helps prevent incorrect responses mistakenly being entered by enforcing certain rules (constraints). These rules have to be met before you can continue with the form. When a response is entered that does not meet the constraint(s) of the field, a warning will show on the handset screen and the fieldworker will be prevented from going to the next field.


Depending on the field type, you can add one or more of the following constraints:


Constraint
Field type applicable to
Must equal constraint
Text; Number; Date; Phone number
Inequality constraint
Numbers; Date
Range constraint
Number; Date
Match constraint
Text; Number; Phone number
Required constraint
All



To add a constraint:

  1. Click on the name of the field you want to add the constraint to.
  2. From the drop-down, select 'Add Constraints'.
  3. A dialog box appears. Choose the type of constraint you want to add from the drop-down list.
  4. Add the value(s) of your constraint.
  5. Select 'Create constraint'If you want to ad more than one constraint, you can add them individually. 
  6. Indicate whether this skip rule should apply only when all the constraints are met, or if any one of the constraints are met. 
  7. Once you've added all your constraints, select 'Save'.





In the example below, the response to this field must be a numeric response with a value greater than or equal to 1. The fieldworker will not be able to continue with this field if the response has any other value. 




Must equal constraint

This constraint performs an exact comparison between two values:

  • Applied to numeric fields, the numbers '8.00000' and '8.0' are not considered exactly the same and the constraint will fail. (Note: you can use the ROUND operator to ensure the number of decimal digits is the same).
  • Applied to text fields, the words 'Test' and 'test' are not considered exactly the same and the constraint will fail (i.e. the constraint is case sensitive).


Example: 

The response to this number field must be exactly equal to 20.5.



Inequality constraint


Inequality constraints compare a numeric or date response to another value using the following inequalities:

  • Greater than (>)
  • Greater than or equal (>=)
  • Less than (<)
  • Less than or equal (<=)
  • Not equal (≠)


Example: 

The response to this number field must be less than or equal to 500.



Range constraint


Range constraints ensure that a specific number or date response falls between two values. You can also add multiple ranges, e.g. allow any value that falls between 100 and 200 or between 300 and 400.


When entering values for this constraint:

  • Applied to a number field - enter the from and to values (both inclusive). 
  • Applied to a date field, enter the from and to dates in the format dd-mm-yyyy.


Example: 

The response to this date field must fall between 26 February 2018 and 26 July 2018 (both dates inclusive).




Match constraint


This constraint validates a response against a predefined algorithm or pattern and is used in conjunction with regular expressions.


Example: 

The response to this field must match the format of a valid South African ID number.  



Read the article on Advanced Validation for more information and examples.


Required constraint

All fields are required by default. This means that you cannot proceed unless a response has been given. You can change field to be optional as shown below. An exclamation mark in the top right corner of the field's box shows the field's status - red (required) or grey (optional).


To make a field optional, i.e. to allow the fieldworker to 'skip' the field:

  1. Hover your mouse pointer over the name of the field you want to make optional.
  2. In the drop-down, select 'Make optional'.
  3. The exclamation mark icon is now grey. 


To make the field required again:

  1. Hover your mouse pointer over the name of the field you want to make optional.
  2. In the drop-down, select 'Make required'.
  3. The exclamation mark icon is now red. 


Example: 

Make a required field optional.