Sometimes you may want to only show or only require (or both) a field if other fields are answered or answered a certain way. For example, you may have a request that looks like:
But you only want to display the Account ID field if it is a remove request, and the Account ID should be required for remove requests.
To do this, we follow the following steps:
- In the builder, select the Request Type question. You will need to use the values, rather than the labels of the answers, and they are not necessarily the same. You will want to check on what the values are. In this case, they are the same.
- Then click on the question we want to control, Account ID. We will be adding Display and Validation conditions.
- When you click on Display, the display options are shown. In this case, it is currently visible, but we only want it to be visible some of the time, so we are going to select Conditional.
- Then we will use the Variables drop down to build our Condition.
which will be
values('Request Type') == "Remove"
- Then we move on to the Validation section. When this is opened it will display a similar conditional.
- Again, select Conditional. This time, when the Condition field displays, we can just copy-paste the condition from the Display section, since we want them to be the same.
Now you are done and the page will look like this when it loads:
Like this when you select “Remove” (note the red star for the required field):
And like this if you try to submit a type of Remove without an Account ID (note the Default Validation message):