How to have dates input to be 18+ years?

  • sheli21
    Asked 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_C
    Replied 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:

    How to have dates input to be 18+ years? Image 1 Screenshot 30

    2) There I disabled future dates and when you scroll down:

    How to have dates input to be 18+ years? Image 2 Screenshot 41

    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!

  • sheli21
    Replied 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_C
    Replied 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.

    How to have dates input to be 18+ years? Image 1 Screenshot 30

    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:

    How to have dates input to be 18+ years? Image 2 Screenshot 41 

    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!

  • sheli21
    Replied 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?

  • WilliamR
    Replied 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.

    How to have dates input to be 18+ years? Image 1 Screenshot 20

    Hope that helps. Let us know if you have any other concerns.

  • Nik_C
    Replied 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.

    How to have dates input to be 18+ years? Image 1 Screenshot 50

    But, maybe we could do this, add one more field that will be prefilled with current date:

    How to have dates input to be 18+ years? Image 2 Screenshot 61

    Then I added a condition that will check if the date entered by the user is before then the current one:

     

    How to have dates input to be 18+ years? Image 3 Screenshot 72

    If it is, the below message will be shown and Submit button will be hidden:

    How to have dates input to be 18+ years? Image 4 Screenshot 83

    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!