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 calculate correct age base on the current date using the form

    Asked by Benflips on July 20, 2016 at 08:59 PM
    Someone gave me this similar workaround a while ago, and I have just played with the cloned form I made, but it doesn't seem to give an accurate result - example, I put in my date of birth 1 Aug 1978 and it said I was 39.

    Now, I WILL be 39 this year, but I am not right now...can the code be tweaked to take account of the days that have elapsed compared with your actual birthday to make sure the result is 100% accurate?

    There is no point using this (otherwise great) code, if the result is off my a year because of the issue as described above.

    calculate age
  • Profile Image
    JotForm Support

    Answered by jonathan on July 20, 2016 at 10:53 PM

    You must be referring to the Calculate Age template form 

    link: https://www.jotform.com/form-templates/calculate-age

     

    I think the Dates Difference widget has the more accurate calculation.

    I will check how it can be applied on the age calculation form also. I'll get back to this as soon as I have update.

    Thanks.

  • Profile Image
    JotForm Support

    Answered by jonathan on July 20, 2016 at 10:57 PM

    I also found a solution that work on another user about the same scenario.

    You can review the thread here

  • Profile Image
    JotForm Support

    Answered by jonathan on July 20, 2016 at 11:12 PM

    Please test this form https://form.jotform.com/62018374848967

    You can also clone the form so you can review it on your Form Builder.

    Let us know if you need further assistance.

  • Profile Image

    Answered by Benflips on July 21, 2016 at 06:20 PM

    How do I clone again?

    I have tested, this does work great.

    Can you just tell me how to insert this into my existing form, using the existing DOB field I have currently on that form - I assume it's a number of hidden fields and calculation rules like earlier suggestions?

  • Profile Image
    JotForm Support

    Answered by jonathan on July 21, 2016 at 06:43 PM

    Please refer to our user guide on how to clone a form.

    User guide: How-to-clone-an-existing-form-from-a-URL

    This is my test form URL https://form.jotform.com/62018374848967 

    -- 

    I suggest you clone the form so that you can better review it on your Form Builder. And you will be able to see also the hidden fields and calculation formula once you have the cloned form.

    Below are also the steps I did to create the form.

     

    The "Your Age" calculation have this formula: (you can see it also on the form once you cloned it)

     

    As you can see I used the floor() function and divide the number of Days by 365.25.

    Just add the necessary fields on your form and use the same formula for the Calculation fields.

    Let us know how we can be of further assistance.

  • Profile Image

    Answered by Benflips on July 21, 2016 at 09:45 PM
    Spectacular. It worked! Thanks.
    Now, can I have some help reducing the Age input (434) to the width of its
    label, and hopefully still having height and weight on the same line.
    Also, can you give me code to change the input field's appearance to look
    'greyed out' or some other appearance to differentiate it from an active
    field requiring an input. I have set the field to read-only, but that
    hasn't changed the field's appearance
    https://www.jotform.com//?formID=43420990799871

    *Regards,*
    *Dr. Ben Phillips*
    Chiropractor
    B.App.Sc.(Comp.Med.)(Chiro) M.Clin.Chiro.(RMIT)
    ...
  • Profile Image
    JotForm Support

    Answered by jonathan on July 21, 2016 at 10:58 PM

    I created a separate thread for the next question here https://www.jotform.com/answers/888322

    We will attend to it shortly.