PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Calculate age from date

  1. placson
    Member

    Is there a way to calculate the person's age based on a date field (MM/DD/YYYY)? I'd like to have the user enter their date of birth and after entering allow a hidden field or read-only field appear that shows their calculated age.

    Posted 8 years ago on Wednesday October 12, 2011 | Permalink
  2. This isn't currently a built in feature. It could be accomplished as a customization.

    - Add a hidden field to your form and position it below the date field
    - Edit this hidden field and give it a Field Label of "Age"
    - Save your form

    Now use the gform_pre_submission hook and some custom code to then read the value of the date field, calculate the age, and store it in your hidden field.

    Documentation for the gform_pre_submission hook can be found here:

    http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    Posted 8 years ago on Wednesday October 12, 2011 | Permalink