-
sheli21Asked on July 2, 2017 at 1:02 PM
Hi there
I need to make a question that asks people's date of birth, but I need to have a minimum age of 18 years old. Which widget can I use and how do I make this restriction that will automatically update each year?
tx
Sheli
-
Nik_CReplied on July 2, 2017 at 2:35 PM
You could use regular date field, with limits, to restrict your users from inputting below 18 years old.
1) So when you have a date field in the form, click Properties button and then Limits:
2) There I disabled future dates and when you scroll down:
You can set the disable range. I added from 1st July 1999 until today so those dates will be disabled. That way you will have only 18+ years.
Please let us know if that could work for you.
Thank you!
-
sheli21Replied on July 2, 2017 at 2:38 PM
Does this mean I will have to adjust this every year manually? Is there no option that does this automatically and takes into account the current year's date?
-
Nik_CReplied on July 2, 2017 at 4:35 PM
It is not possible to do that with built-in options, but it is possible by using some additional fields, widgets, and conditional logic.
I added two fields to the form for dates, today's date, and birthday date. Also, I added few fields that will hold some temporary calculations and widgets that will extract the year from date fields. Last, I subtracted birth year from today's year. And if the year is < 18 then the message will be shown.
From the image above you can see which fields I used, additionally, I used Substring widget (https://widgets.jotform.com/widget/substring) so I could extract the year from the date field.
Here are the conditions I used:
But maybe the best would be to check my form: https://form.jotformpro.com/71825899304972 and if needed you can Clone it and check the structure.
Please let us know your thoughts.
Thank you!
-
sheli21Replied on July 3, 2017 at 4:27 AM
that is great, is there any way that today's date can be filled in automatically? so that they cannot cheat the system and enter in a different date for today?
-
WilliamRReplied on July 3, 2017 at 4:33 AM
Yes, you can set today's date as the default date on your form. Here's how to do it. Under the Date Picker properties > Options > Default date. Choose the Current option.
Hope that helps. Let us know if you have any other concerns. -
Nik_CReplied on July 3, 2017 at 4:47 AM
I saw that and had the same thought like you, regarding the cheating. But the issue is that the Substring widget will not be triggered if the field is not clicked and dates are not selected.
There is an option for a Date field to be prefilled like shown by my colleague above, but again, that will not work, because of the Substring widget problem I mentioned.
That's why I added a condition that when the current date is filled, that field becomes disabled, so it can not be changed anymore, so the cheating is lowered a bit.
But, maybe we could do this, add one more field that will be prefilled with current date:
Then I added a condition that will check if the date entered by the user is before then the current one:
If it is, the below message will be shown and Submit button will be hidden:
I updated my form https://form.jotformpro.com/71825899304972 so please check. Also, I removed the above condition that will disable Current date if filled because users wouldn't be able to change if they make a mistake, accidentally or purposely.
Please let us know your thoughts.
Thank you!