- sheli21Asked on July 02, 2017 at 01:02 PM
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?
- JotForm SupportNik_CAnswered on July 02, 2017 at 02: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.
- sheli21Answered on July 02, 2017 at 02: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?
- JotForm SupportNik_CAnswered on July 02, 2017 at 04: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:
Please let us know your thoughts.
- sheli21Answered on July 03, 2017 at 04: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?
- WilliamRAnswered on July 03, 2017 at 04: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.
- JotForm SupportNik_CAnswered on July 03, 2017 at 04: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.