Calculate the age of a person that is filling in the digital form

Last updated Feb 03 2019

In this demo we will show you how to:
- calculate the exact age of the person who is filling our form, based on his date of birth.


In our form we will use:

- a date field to collect the birth date of the filler
- and calculated control to perform the calculation.
We will also use the String mode calculator and Javascript to create a function.

 

script:

 

(function ()
{
var today = new Date();
var dateParts = FORM_FIELD_HERE.split("/");
var formDate = new Date(dateParts[2], dateParts[0] - 1, dateParts[1]);
var age = today.getFullYear() - formDate.getFullYear();
var monthDiff = today.getMonth() - formDate.getMonth();
if(monthDiff <0 || (monthDiff === 0 && today.getDate()< formDate.getDate()))
{
age--;
}
return age;
})();

Read more information about using the calculated field

 

CommentsLogin Required
Didn’t find what you were looking for?
Try the following for assistance or Use the Search box.