How can I conditionally present a form to my respondents based on their calculated age?

  • Profile Image
    Willsie
    Asked on March 09, 2018 at 05:00 PM

    I have attached the URL to my main page below.

    I have two forms in MyForms based on age of the registrant.

    How do i select the proper form based on the age ? If the registrant is 17 Years old and Younger they get one form and if they are 18 Years old or older they get the other form.

    Thanks

  • Profile Image
    Kevin_G
    Answered on March 09, 2018 at 06:34 PM

    It's possible to do that, you will only need to add a Form Calculation widget to perform the calculations and get the user's age. 

    Firstly, I would recommend you to set the default date to the today's date, to do it you only need to open the field settings, go to the options tab and select "current" on the default date option: 

    1520637770screenshot_01.png

    You may also hide the field so the user only provides his birth date: 

    1520637878screenshot_02.png

    Once you have done this you will only need to add the Form Calculation widget to your form with the formula (today's date - birth date)/365.25.

    1520638066screenshot_01.png

    1520638083screenshot_02.png

    Then based on the date you may change the redirection when the user submits the form. 

    Please check this guide to get more information about the date calculations that you can perform: https://www.jotform.com/help/443-Mastering-Date-and-Time-Calculation 

    This guide will help you changing the thank you link based on the age: https://www.jotform.com/help/317-Change-Thank-You-Page-URL-Based-on-a-Condition 

    If you want, you may also show the link to another form if you want instead of redirect the user upon the submission, this guide will help you showing/hiding elements on the form: https://www.jotform.com/help/316-How-to-Show-or-Hide-Fields-Base-on-User-s-Answer 

    Here's a sample form as well so you can see how the age calculates: https://form.jotform.com/80677026564967 

    If you have questions, please let us know. 

  • Profile Image
    Willsie
    Answered on March 10, 2018 at 08:43 AM
    When i enter the participants date of birth i get -17556.81 in the age
    field ?
    ...
  • Profile Image
    TREVON
    Answered on March 10, 2018 at 01:29 PM

    This may be because of choosing a wrong date as I could not replicate an issue similar to what you have shared. I have however made changes to the form to limit such error. I have made the current day field a read only to avoid users filling this field causing error.

    https://form.jotform.com/80677026564967

    Kindly feel free to clone test and use the above form.


  • Profile Image
    Willsie
    Answered on March 10, 2018 at 02:43 PM
    Thanks Trevon. I cloned it and it works great.
    I have spent the morning reading the user guide and on the help forum
    looking for answers to my next step.
    Now that I have the participants age calculated and populates on the
    "Waiver Form" how do i link to the proper form in MyForms according to the
    age.
    Since the participant is over 18 Years of age, i need it to go into MyForms
    and bring up the form "18 & Over Waiver Form"
    Can this be done ?
    Thanks
    ...
  • Profile Image
    Jim_R
    Answered on March 10, 2018 at 05:28 PM

    I guess your goal is to present these 2 different forms to your users based on their age:

    🔘 18 & Over Waiver Form

    🔘 17 & Under Waiver Form

    Since these are 2 separate forms, you can approach this as follows. Both methods below will require 3 forms in total - FIRST FORM will be your main form, SECOND FORM will be for the 18 and over and the THIRD FORM will be 17 and under.

    1. Either use CONDITIONS + the IFRAME EMBED WIDGET. The idea is to add 2 iframe embed widgets on your first form (for the second and third forms respectively), then conditionally show these based on the respondents calculated age.

    e.g.

    IF age IS GREATER THAN 18 THEN SHOW the iframe embed widget for the 18 & Over Waiver Form

    IF age IS LESS THAN 18 THEN SHOW the iframe embed widget for the 17 & Under Waiver Form

    Related guides:

    How-to-Show-or-Hide-Fields-Base-on-User-s-Answer

    How-to-Add-a-Widget-to-your-Form

    2. Or you can have your users submit the first form, then redirect them conditionally to the second or third form based on the calculated age.

    Related guide: Change-Thank-You-Page-URL-Based-on-a-Condition