Search code examples
javascriptpdfeventsadobeacrobat

How do I trigger javascript events when a signature is cleared in Acrobat 11?


In Adobe Acrobat Standard XI (11), is there a way to trigger a JavaScript event when a signature is cleared?

There is a built-in interface for performing certain actions when a signature is added, but not for when it is removed.

I want to lock down certain fields when the signature is added, and also auto-populate a date field next to the signature. My code for this is working fine. The problem is, when this signature is cleared, I want to unlock all those fields I previously locked down, and then remove the date.

When using the built-in "Lock these fields" feature of the signature actions, it successfully locks and unlocks the fields when the signature is added and removed, but it cannot be further customized to populate a date field as well.

If it really comes down to it, I can just ditch my custom date code, but I really want there to be a way to make this work!


Solution

  • Thanks to a suggestion by Max Wyss, I found a solution that works quite nicely. The calculated value field was the key. Though I didn't use the signatureValidation() method since this is not recommended by the documentation, it was unnecessary because I only needed to check for the presence of a signature.

    This is all I needed. In the calculated custom script for my date field:

    if (getField("mySig").value !== '') // signature is present
        getField("myDate").value = global.getCurDate(); // custom function for a mm/dd/yyyy date
    else
        getField("myDate").value = '';
    

    This may not be the final solution to my problem as this will calculate the date quite often, where I want the date to appear once when the field is signed and then to remain there indefinitely, but it does answer how to trigger an event when a signature is cleared.