Skip to main content
rakeshk21205956
Inspiring
September 23, 2017
Answered

Reset Text FIeld when Date is changed

  • September 23, 2017
  • 1 reply
  • 1353 views

Hello,

I am making a form in Adobe Acrobat Pro  in which i want to reset a Text Field to value 1 whenever the Date is changed.

I have two Text Field  :  

Text1 = Date field this field auto-populates the current date when the file is opened

Text2 - this field has to be reset to "1"  every time the date is changed.

Like if the form is opened today  eg. 23/09/2017 ... i can enter any number in Text2 and save it................. but if the file is opened next day..... Text2 should be reset to 1 then on 24/09/2017 i can enter any number in text2  and save it..... but when again on 25/09/2017 if i open the file text 2 should be reset to "1".

Thanks in advance.

This topic has been closed for replies.
Correct answer try67

Thank you sir....

Your script worked absolutely as the way i wanted...................

I put the script in the button1.

i stuck in other problem ........ i want the Text 2 to get incremented if i click the button in the same date...

Like if i open the file today and click the button . text1  = today date and Text2 = 1 .. i saved it ...... and closed the form..... now after few hours i want to open the file again... and this time if i click the button (on the same date)   Text 1 = today date and Text 2 = 2 and so on..........

I modified your script to the following but it doesnot seem to work

var currentValue = this.getField("Text1").valueAsString; 

var newValue = util.printd("yymmdd", new Date()); 

if (currentValue!=newValue)

{this.getField("Text2").value = "1"; 

this.getField("Text1").value = newValue;}

else {

this.info.ID = 1;

this.getField("Text2").value = this.info.ID++;

}


Use this:

this.getField("Text2").value = Number(this.getField("Text2").value)+1;

1 reply

try67
Community Expert
Community Expert
September 23, 2017

Post the code you used for Text1.

rakeshk21205956
Inspiring
September 23, 2017

I used the following script to auto-populate the Text1 (current date) with the help of a button :

this.getField("Text1").value = util.printd("yymmdd", new Date();

try67
Community Expert
Community Expert
September 23, 2017

OK. Use this code instead:

var currentValue = this.getField("Text1").valueAsString;

var newValue = util.printd("yymmdd", new Date());

if (currentValue!=newValue) this.getField("Text2").value = "1";

this.getField("Text1").value = newValue;