What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How to have dates input to be 18+ years?

    Asked by sheli21 on July 02, 2017 at 01: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

  • Profile Image
    JotForm Support

    Answered by Nik_C 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.

    Thank you!

  • Profile Image

    Answered by sheli21 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?

  • Profile Image
    JotForm Support

    Answered by Nik_C 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:

     

    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!

  • Profile Image

    Answered by sheli21 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?

  • Profile Image

    Answered by WilliamR 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.

  • Profile Image
    JotForm Support

    Answered by Nik_C 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.

    Thank you!