Required Conditional Questions Survey 123

639
3
Jump to solution
03-29-2023 08:31 AM
FavaN2021
New Contributor III

Hello! I am currently working on a compliant form, and often the complainant will not know the date or time of their visit but have a general idea or time frame.

At the moment, I have a date and time question and start time and end time, IF the date and time question are left NULL, I want the survey to required the end user to fill out the start and end time BUT only if the date and time question are null. Is this possible? 

0 Kudos
1 Solution

Accepted Solutions
Vinzafy
Occasional Contributor

Hey there,

If I'm understanding it right, you have a dateTime question along with a time question for Start Time and another time question for End Time. You want the two Time questions to be required IF the dateTime question is not filled?

If so, this can definitely be achieved by converting the dateTime question to a string and setting a formula in the required column for the time questions. 

If you convert the dasteTime question to a string, when it's blank the value it returns is 0. Thus, we want to set the required condition for the time questions to only be required if the string-length of the dateTime question is 0. 

In the "required" column for the two time questions, use the following formula;

string-length(${<dateTime question name>}) = 0

This makes the start and and time questions required when dateTime is blank.

Vinzafy_0-1680106161194.png

But not required when dateTime is filled

Vinzafy_1-1680106474439.png

Hope I understood that right! If that needs to be altered for dateTime questions as opposed to just time questions, the same required calculation should still be valid. 

View solution in original post

3 Replies
Vinzafy
Occasional Contributor

Hey there,

If I'm understanding it right, you have a dateTime question along with a time question for Start Time and another time question for End Time. You want the two Time questions to be required IF the dateTime question is not filled?

If so, this can definitely be achieved by converting the dateTime question to a string and setting a formula in the required column for the time questions. 

If you convert the dasteTime question to a string, when it's blank the value it returns is 0. Thus, we want to set the required condition for the time questions to only be required if the string-length of the dateTime question is 0. 

In the "required" column for the two time questions, use the following formula;

string-length(${<dateTime question name>}) = 0

This makes the start and and time questions required when dateTime is blank.

Vinzafy_0-1680106161194.png

But not required when dateTime is filled

Vinzafy_1-1680106474439.png

Hope I understood that right! If that needs to be altered for dateTime questions as opposed to just time questions, the same required calculation should still be valid. 

FavaN2021
New Contributor III

@Vinzafy thank you so much. This is exactly what I needed. 

Vinzafy
Occasional Contributor

Fantastic! Glad that worked for you 🙂