Date Field Displays Date 3 Days Prior to Another Date Field

Community Beginner ,
Feb 26, 2021 Feb 26, 2021

Copy link to clipboard

Copied

I have a simple form that has two date fields "TestDate" & "DepatureDate".  I need the TestDate field to auto-display a date three days prior to whatever date is entered in DepartureDate. The DepartureDate is a changable field, but the TestDate cannnot be edited.  Everything I seemed to see had to do with subtracting from CURRENT date, but that's not helpeful.

TOPICS
JavaScript, PDF forms

Views

47

Likes

translate

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

Adobe Community Professional , Feb 26, 2021 Feb 26, 2021
You can make the TestDate field read-only and use a custom calculation script in it like this:   // The field value will remain blank until the DepartureDate field shows a date value event.value = ""; /* declare a condition, if DepartureDate field is not blank calculate the date selected in that field minus 3 days */ if (this.getField("DepartureDate").value !="") { var depart = util.scand("dd mmm yy", this.getField("DepartureDate").value); depart.setDate(depart.getDate() - 3); event.value ...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Feb 26, 2021 Feb 26, 2021

Copy link to clipboard

Copied

You can make the TestDate field read-only and use a custom calculation script in it like this:

 

// The field value will remain blank until the DepartureDate field shows a date value

event.value = "";

/* declare a condition, if DepartureDate field is not blank calculate the date selected in that field minus 3 days
*/

if (this.getField("DepartureDate").value !="") {

var depart = util.scand("dd mmm yy", this.getField("DepartureDate").value);

depart.setDate(depart.getDate() - 3);

event.value = util.printd("dd mmm yy", depart);

}

Likes

translate

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