Highlighted

auto updating date fields

Explorer ,
Sep 27, 2020

Copy link to clipboard

Copied

Hi, I want an auto date for two text fields. so every time i open this form, bellow two field dates should auto-update. can u pls help me to do this using javascript. thanks..

 

1. First payment date = Today date + two months
2. Second payment date = First payment date + 1 Year

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can do it by placing the following code under Tools - JavaScript - Document JavaScripts (NOT inside a function):

 

var f1 = this.getField("Date1");
var f2 = this.getField("Date2");
var d1 = new Date();
d1.setMonth(d1.getMonth()+2);
f1.value = util.printd("mm/dd/yyyy", d1);
d1.setFullYear(d1.getFullYear()+1);
f2.value = util.printd("mm/dd/yyyy", d1);

Adjust the field names and date pattern as needed.

TOPICS
Acrobat SDK and JavaScript

Views

64

Likes

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

auto updating date fields

Explorer ,
Sep 27, 2020

Copy link to clipboard

Copied

Hi, I want an auto date for two text fields. so every time i open this form, bellow two field dates should auto-update. can u pls help me to do this using javascript. thanks..

 

1. First payment date = Today date + two months
2. Second payment date = First payment date + 1 Year

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You can do it by placing the following code under Tools - JavaScript - Document JavaScripts (NOT inside a function):

 

var f1 = this.getField("Date1");
var f2 = this.getField("Date2");
var d1 = new Date();
d1.setMonth(d1.getMonth()+2);
f1.value = util.printd("mm/dd/yyyy", d1);
d1.setFullYear(d1.getFullYear()+1);
f2.value = util.printd("mm/dd/yyyy", d1);

Adjust the field names and date pattern as needed.

TOPICS
Acrobat SDK and JavaScript

Views

65

Likes

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
Sep 27, 2020 0
Most Valuable Participant ,
Sep 27, 2020

Copy link to clipboard

Copied

You can do it by placing the following code under Tools - JavaScript - Document JavaScripts (NOT inside a function):

 

var f1 = this.getField("Date1");
var f2 = this.getField("Date2");
var d1 = new Date();
d1.setMonth(d1.getMonth()+2);
f1.value = util.printd("mm/dd/yyyy", d1);
d1.setFullYear(d1.getFullYear()+1);
f2.value = util.printd("mm/dd/yyyy", d1);

Adjust the field names and date pattern as needed.

Likes

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
Reply
Loading...
Sep 27, 2020 0
omanbux LATEST
Explorer ,
Sep 29, 2020

Copy link to clipboard

Copied

Thank you very much. it's working perfectly.

Likes

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
Reply
Loading...
Sep 29, 2020 0