Skip to main content
mbcrossman
Participant
November 23, 2016
Question

How do I automatically populate an EXP date from a date field that is manually entered in PDF form?

  • November 23, 2016
  • 3 replies
  • 757 views

I am using Adobe Acrobat to make gift certicates. I want to be able to manually enter the issue date and have the expiration populate a year out from the issue date.

Can someone help me with the action script for this? I have tried various scripts and none seem to work correctly.

I have been entering the script in the properties of the expiration date as an action. If I should be doing this different please advise. I am a novice with forms and action scripts.

Thank you in advance.

MB

This topic has been closed for replies.

3 replies

mbcrossman
Participant
November 23, 2016

it is a 4 digit. just a typo. when i did enter script i was using mm/dd/yyyy.

Inspiring
November 27, 2016

To change the EpirationDate only when the IntialDate is changed, I would add the following script to the "onblur" action for the InitialDate:

// on blur action for IssueDate; changes ExpirationDate only when this field changes;

this.getField("ExpirationDate").value = "";

if(event.value != "")

{

// convert value to date object;

var oDate = util.scand("mm/dd/yyyy", event.value);

// add one year to date object;

oDate.setFullYear(oDate.getFullYear() + 1);

// set expiration date to formatted value;

this.getField("ExpirationDate").value = util.printd("mm/dd/yyyy", oDate);

}

The ExpirationDate has a format of "None" the above script performs the necessary formatting.

mbcrossman
Participant
November 23, 2016

Nothing I have done has worked. Don't even know where to start with what I have tried to use for script.

Could you help me at all with how to make this happen?

I need the field "ExpirationDate" to populate a year out from a the manually entered field "IssueDate"

Both of those fields are specified as date with "mm/dd/yyy" format.

Lets start from the beginning. I know nothing.

Inspiring
November 23, 2016

The format options for "date" do not include the 3 digit year. It is either 2 digits or 4 digits.

If you have the format for the date wrong in the "util.scand" method you should be getting an error in the JavaScript console.

All of this script must be a custom JavaScript.

Inspiring
November 23, 2016

Acrobat forms use "JavaScript", action script offered by Adobe in other products does not work with Acrobat forms.

Exactly in what action did you place this script?

What is the script you are trying to use?