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

Date in a PDF Form Changing when PDF is Opened Next Day - How to Lockdown the Date Field?

New Here ,
Jul 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Hi,

 

I am facing an issue with a PDF form that is used and signed by mutiple people. As per the process, once first person completes his form fields, he presses the First "Completed" button and the current date must be displayed against his name in a previously hidden field (I have programmed the button to make date field visible once button is pressed). Then the form goes to second person. When the second person completes his form fields, he presses the Second "Completed" button and the current date must be displayed against his name in a previously hidden field.

 

The problem I am facing is that I am able to get the current date, but when the PDF is opened on the next day, the date keeps changing to reflect new date. I don't want this and need to lock the date field once a date is populated for record. I have tried making the field readonly after the current date is populated first time, but still the date gets changed automatically the next day.

 

The current Custom Calculation Script used by me in a text field is:
event.target.value = util.printd("mm/dd/yyyy", new Date());
event.target.readonly = true;

 

Can anyone provide guidance on this?

TOPICS
How to , JavaScript , PDF , PDF forms

Views

347

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 2 Correct answers

Community Expert , Jul 22, 2024 Jul 22, 2024

Set the value only when the field is empty.

Votes

Translate

Translate
Community Expert , Jul 22, 2024 Jul 22, 2024

This is incorrect:

fld.display = fld.visible;

It should be:

fld.display = display.visible;

Votes

Translate

Translate
Community Expert ,
Jul 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Set the value only when the field is empty.

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Thank you Bernd for you quick reply!

 

Sorry to ask this, but can you please put it in a sample code for me?

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Like this:

if (event.target.value == "") event.target.value = ...

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Thank you!

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Put the entire script in a mouse up action in the button field like this:

var fld=this.getField("Date");

fld.value = util.printd("mm/dd/yyyy", new Date());

fld.display = display.visible;

You could also disappear the button if it is no longer needed:

event.target.display = display.hidden;

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

This is incorrect:

fld.display = fld.visible;

It should be:

fld.display = display.visible;

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

Thank you - This was helpful!

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, 2024 Jul 22, 2024

Copy link to clipboard

Copied

LATEST

Thank you so much!

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