If you are collecting date of birth using a date picker input type, you can convert that date to the users (current) age in years or month for submission, or use in branching to different box pages. To do this, install App #69: Convert Date to Years Or Months. Do this from the profile menu top right, select Custom JS (Apps), and find App #69 in the “Available” tab.
Then, you can use a Date Picker field in your form to collect the date, and configure metadata on the field as follows:
Note that Date Pickers already support validation of age, you can set a min and max value that the form will accept.
If you need to store the age, or act on in later in the Box experience, the command options (metadata keys) are:
- date_toageyears: number of years from entered date to now (rounded down)
- date_toagemonths: number of months, rounded down
The metadata value should be the name of the field where you want to store and submit the calculated age, in the format custom_1, custom_2, etc. Make sure that this field is not being used by another form on a different page. And, of course, you will need to map whatever field you choose in an integration.
Comments? Questions? Let us know at support@digioh.com