Making either one of them required

Hello ODKers,
Can we make either of them required i.e consider there is a question regarding mobile number and landline number . If he has only one so i want either of them to be mandatory not both . Is this possible in ODK?.

Thanks and regards,

SGSC

Hi!

One option is to have the form ask one question:
What is your mobile number?
And make this first question NOT required.

Then, have a second question which pops up:
What is your land-line?

  • make the second question REQUIRED
  • make this second question relevant - it should only pop up if the first question is left blank

I would use hints in both questions to tell the data collector that either the mobile number or the landline must be entered.

I would also use a regex constraint to ensure the data collector entered the right number of digits in each phone number.

Does that solution make sense? This would ensure that you are always collecting the mobile number, but in case they don't have one, then your form would require a landline number.

Hope that helps! Let me know if something doesn't make sense!
Janna

Hello @janna,

Thanks for the reply . I thought of this solution that i would ask the landline number on the next screen if data collector does not enter the mobile number , but i want to club these two questions on one screen so i want to try another way (In app relevant condition works on swipe) . Could you please suggest any other way .

Thanks and regards,

SGSC

Hi @SGSC!

How about this.
Make both phone numbers required, text entry.
In the constraint use a regex that requires either a '0' entry OR a 9-digit number entry (or however long your phone number is).
In the constraint of your second phone number, add an AND constraint that doesn't allow mobile_number to be equal to landline_number.

I wonder if that would work for you? It would require your data connector to enter 0 if they didn't want to input a phone number. But then they couldn't enter 0 twice.

See if that works. If not, let me know, and we can continue brainstorming!
Thanks, Janna

hello @janna ,
But then how would i make either one of them required . Actually i had a thought . I will check if mobile is empty . If yes then landline number is not mandatory if not then it is mandatory . But how to write that in the form .I have tried by writing if([condition],"required=true()","required=false()") , but this was not working .

Thanks and regards,

SGSC

Hi @SGSC,

What you want to achieve is a bit complex to what odk can do, if text field mobile is empty then landline mandatory and vice versa. To achieve this you will need another question as a control. This is because i dont think in odk you can call a variable yet to be defined. I have implemented form to explain what i meanmobile_landline.xls (20.5 KB)