• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

script to calculate age

New Here ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

Hi Team,

 

I am after a script to workout a persons age based on their date of birth. the dob field is called DOB and i use dd/mmm/yyyy

 

TIA

TOPICS
JavaScript , PDF forms

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 22, 2021 Jul 22, 2021

Votes

Translate

Translate
Adobe Employee ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

Hi Ben

 

Hope you are doing well and sorry for the trouble.

 

The workflow you are trying to achieve is possible using the JavaScript. For more information please check out the help page https://acrobatusers.com/tutorials/javascript_console/

 

Hope it will help

 

Regards

Amal

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

not sure how to make it work for my needs though

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

LATEST

Try use this as "Custom calculation script" in field where you want to show age:

event.value = "";
var dv = this.getField("DOB").value;
if (dv!="") {
var dob = util.scand("dd/mmm/yyyy", dv);
var today = new Date();
var age = today.getFullYear() - dob.getFullYear();
if (today.getMonth() < dob.getMonth()) age = age - 1;
if ((today.getMonth() == dob.getMonth()) && (today.getDate() < dob.getDate())) age -= 1;
event.value = age;}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

This issue was discussed on the forums many times, including complete code examples of how to do it. Try searching around a bit of "age calculation" or similar keywords...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines