Conditional Logic: Help to check if it's minor with current date value to check against it

  • Haberle
    Asked on June 20, 2024 at 1:43 PM

    I would like to add conditional formatting to form elements based on the calculation of the birth date field. This can almost be done using conditions but you have to set a specific date value for it to check against. There is no option to have a "current date" value for it to check against, meaning it would have to be constantly updated to account for future dates. Thank you.

    Jotform Thread 16111391 Screenshot
  • Jessica JotForm Support
    Replied on June 20, 2024 at 1:45 PM

    Hi Haberle,

    Thanks for reaching out to Jotform Support. We’ll need a bit of time to look into this. We'll get back to you as soon as we can.

    We appreciate your patience and understanding in this.

  • Jessica JotForm Support
    Replied on June 21, 2024 at 12:36 AM

    Hi Haberle,

    To check if the respondent is minor or not, with current date value to check against it, so there is no need to update for future dates, you'll need to setup calculations to calculate the respondent's age. To do this, we'll need to have 4 different elements in your form:

    1. One Date Picker element for the respondent to choose their birthday
    2. One Date Picker element automatically set to current date.
    3. One Form Calculation to check the days difference.
    4. One Form Calculation to check the years difference.

    Here is how the form will look like once it is set up. You can also test the demo form here, and clone the form to check the settings more:

    Conditional Logic: Help to check if its minor with current date value to check against it Image 1 Screenshot 80

    Now, let me guide you on how to set it up:

    First, you will need to add Date Picker and Form Calculation into your form. It's easy to do this, let me show you how:

    1. In Form Builder, click on Add Form Element+.
    2. Date Picker can be found under Basic tab.
    3. Form Calculation can be found under Widget tab.
    4. Click or drag and drop to add it to your form.
    5. You can also rename it according to your preferences.

    Conditional Logic: Help to check if its minor with current date value to check against it Image 2 Screenshot 91

    Second, you will need to set up one of Date Picker element's, "Today", to automatically populate current date:

    1. Click on one of Date Picker's element.
    2. Click on gear icon.
    3. Click on Options.
    4. Under Default Date, select Current.

    Conditional Logic: Help to check if its minor with current date value to check against it Image 3 Screenshot 102

    Third, we'll need to configure one of Form Calculation's element, "Age - days", to calculate the day difference:

    1. Click on one of Form Calculation's element.
    2. Click on gear icon.
    3. Add the following calculation:
      Conditional Logic: Help to check if its minor with current date value to check against it Image 4 Screenshot 113
      You will need to click on Add Field to add the other two Date Picker fields.
    4. Click on Save.

    Conditional Logic: Help to check if its minor with current date value to check against it Image 5 Screenshot 124

    Fourth, we'll need to configure one of Form Calculation's element, "Age - year", to calculate the year difference:

    1. Click on one of Form Calculation's element.
    2. Click on gear icon.
    3. Add the following calculation:
      Conditional Logic: Help to check if its minor with current date value to check against it Image 6 Screenshot 135
      You will need to click on Add Field to add the other two Date Picker fields.
    4. Click on Save.

    And, you are good to go. You can also hide these fields when you do not need them to appear in the form by right-click on the element, then select Hide.

    Conditional Logic: Help to check if its minor with current date value to check against it Image 7 Screenshot 146

    Give it a try and let us know if you need more help.

 
Your Answer