Question validation
We can apply validation to certain types of text entries. For example, we can ensure that a phone number or email address is correctly formatted.
Validate postcodes
Activity
- Click
Add field
. - Choose
Text box
. - Type Postcode in the
Field
Label and type postcode in theVariable Name
. - In the
Validation
field, select Postal code (Australia). This will ensure only four numerals can be entered into the field. - In the
Field
note field, type “Providing your postcode is optional. We collect approximate residency data to assist with interpreting trial results.” - Click
Save
.
Validate emails
Activity
- Click
Add field
. - Choose
Text box
. - Type Email in the
Field
Label and type email in theVariable Name
. - In the
Validation
field, select Email. This will ensure only correctly formatted emails can be entered into the field. - In the
Identifier
field, select “Yes”. - Click
Save
. - Click
Return to list of instruments
.
Validate dates
Activity
- Click
Add field
. - Choose
Text box
. - Type Date of Birth in the
Field
description and type dob in theVariable Name
. - In the
Validation
field, select Date (D-M-Y). This will ensure only dates can be entered into the field.
Validate numbers
Activity
- Create two new text box fields: for Height (cm) (Variable Name: height_cm) and Weight (Kg) (Variable Name: weight_kg) using the instructions above.
- For each one, set the
Validation
to Integer. This will ensure only numbers can be entered into the field.