Search the knowledge base, browse our resources, and visit our forum for more detailed information
Last updated: 25 Nov 2025
Required logic allows you to make a question mandatory if specific conditions are met. For example, you can require a phone number question only if respondents agree to be contacted in the future. This option provides more control than simply marking a question as always required or always optional.
To learn more about required questions and how to customize the message shown to respondents when they leave a required question unanswered, see Using question options in XLSForm.
This article explains how to add required logic conditions in XLSForm, including making a question required based on whether another question was answered.
Note: This article focuses on adding required logic in XLSForm. To learn about adding required logic in the KoboToolbox Formbuilder, see Using the question options.
For hands-on practice with required logic in XLSForm, see KoboToolbox Academy’s XLSForm Fundamentals Course.
Required logic uses question referencing to make questions required based on previous answers. The question used to define the required logic is referred to as the reference question.
To add required logic in XLSForm:
Add a required column to the survey worksheet.
In the row of the question you wish to set the required logic for, enter the condition that must be met in order for the question to be mandatory.
survey worksheet
type |
name |
label |
required |
|---|---|---|---|
select_one yn |
recontact |
Do you agree to being contacted again for another study in the future? |
|
text |
What is your email address? |
${recontact} = ‘yes’ |
|
survey |
If a respondent does not answer a required question, they will not be able to proceed to the next page of the form or submit it.
The format of the required logic condition will differ according to the type of the reference question, as detailed in the table below.
Reference question type |
Required logic condition |
Example |
|---|---|---|
select_one |
|
|
select_multiple |
|
|
integer |
|
|
date |
|
|
To learn more about building form logic expressions in XLSForm, see Introduction to form logic in XLSForm.
In addition to setting required logic for a specific response, you can also base it on whether a question was answered or left blank. This is useful when you want to ensure that at least one of two questions is required.
Unanswered questions are treated as empty strings, noted as two single apostrophes ''. The following required logic conditions can be used:
Required logic condition |
Description |
|---|---|
|
Require only if |
|
Require only if |
survey worksheet
type |
name |
label |
required |
|---|---|---|---|
note |
contact |
Please provide your phone number or email address below. |
|
text |
phone |
Phone number |
|
text |
Email address |
${phone} = ‘’ |
|
survey |
Did you find what you were looking for? Was the information clear? Was anything missing?
Share your feedback to help us improve this article!
KoboToolbox is maintained by Kobo Inc.