Skip to main content
Inspiring
October 5, 2023
Question

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

  • October 5, 2023
  • 3 replies
  • 2697 views

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;

This topic has been closed for replies.

3 replies

Abambo
Community Expert
Community Expert
October 5, 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
try67
Community Expert
Community Expert
October 5, 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.

MBChelsAuthor
Inspiring
October 5, 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.

try67
Community Expert
Community Expert
October 5, 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?

MBChelsAuthor
Inspiring
October 5, 2023

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

try67
Community Expert
Community Expert
October 5, 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.

Bernd Alheit
Community Expert
Community Expert
October 5, 2023

Where does you use the script? 

MBChelsAuthor
Inspiring
October 5, 2023

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

MBChelsAuthor
Inspiring
October 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?