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

How to add date in a date field after signature then clear it after clearing signature

Participant ,
Oct 05, 2023 Oct 05, 2023

The following code works to add a date in "Date1" field but when I try to clear the same signature, the date still remains.

 

What am I missing?

 

if (getField("Signature1").value !== '')// signature is present
this.getField("Date1").value= "";

else
var currentTime = new Date()

var month = currentTime.getMonth() + 1

var day = currentTime.getDate()

var year = currentTime.getFullYear()

var signingTime = day +"/"+month+"/"+year //Modify into your preferred format

var f = this.getField("Date1"); //Modify the field name as necessary

f.value = signingTime;

TOPICS
JavaScript , PDF
2.9K
Translate
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 ,
Oct 05, 2023 Oct 05, 2023

Where does you use the script? 

Translate
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
Participant ,
Oct 05, 2023 Oct 05, 2023

In the Digital Signature Properties under the 'signed' tab, 'This script executes when field is signed:'

Translate
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
Participant ,
Oct 17, 2023 Oct 17, 2023

I figured out how to copy the date using this thread:

Solved: Can Acrobat auto populate a date field upon digita... - Adobe Community - 4524073

 

This works to clear the date using the following code:

if (getField("IT Signature").value !=='')// signature is present

getField("IT Date").value = ''; //blank if signature cleared

 

How do I change the code so that it will clear when the signature is NOT present?

Translate
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 ,
Oct 17, 2023 Oct 17, 2023

Change:

if (getField("IT Signature").value !=='')

To:

if (getField("IT Signature").value=='')

Translate
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
Participant ,
Oct 17, 2023 Oct 17, 2023

Dang.  That doesn't work.  It doesn't clear the date field upon clearing the signature.  It only clears it if you click the  signature field again after you clear it (then hit cancel).

Translate
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 ,
May 04, 2024 May 04, 2024
LATEST

Were you able to figure it out?

I'm trying to reformat a document and they want the date field to clear along with the signature.

I'm still fairly inexperienced with javascript so anything I can mess around with will help

Translate
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 ,
Oct 05, 2023 Oct 05, 2023

Digital signatures fields already show the date when you sign them, and it is removed when you clear them.

Why re-invent the wheel?

Translate
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
Participant ,
Oct 05, 2023 Oct 05, 2023

I agree but the people wanting me to do this think the date is too small and they want something more obvious.

Translate
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 ,
Oct 05, 2023 Oct 05, 2023

Well, you can't really do that, as clearing a signature does not trigger any events. You could use a script at doc-load or save to clear the date field if the signature field is empty, though.

Translate
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 ,
Oct 05, 2023 Oct 05, 2023

After signing a document, it should not be possible to modify that document. That's against the essence of a signature.

ABAMBO | Hard- and Software Engineer | Photographer
Translate
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 ,
Oct 05, 2023 Oct 05, 2023

That's not entirely true. Form fields can remain editable, unless the signature is set to lock them.

However, the signature will not be valid if you edit them, as the file has been changed.

Other signatures can also be applied, and that should keep the original signature valid.

Translate
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
Participant ,
Oct 05, 2023 Oct 05, 2023

Yes sir.  I have that field marked as read only so it cannot be edited.

The only thing I have to do is clear it once the signature is cleared.  I have looked everywhere and other posts claim to have it worked but I haven't been able to.

Translate
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
Participant ,
Oct 17, 2023 Oct 17, 2023

I figured out how to copy the date using this thread:

Solved: Can Acrobat auto populate a date field upon digita... - Adobe Community - 4524073

 

This works to clear the date using the following code:

if (getField("IT Signature").value !=='')// signature is present

getField("IT Date").value = ''; //blank if signature cleared

 

How do I change the code so that it will clear when the signature is NOT present?

 

Translate
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