Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to auto-validate Digital Signature field using Javascript?

Avatar

Former Community Member
Hi all,



I would need to validate my digital signature field upon opening the pdf form. I know there is an option to auto-verify signatures on opening, but some how that is not working.



I tried putting the signatureValidate() method on the doc:ready event, but that will cause an error.



I have tried putting this method to run when I click a button and that works.



So may I ask where to put this method so that I can validate digital signatures? Is there a timer function where I can use to wait for the form to be fully loaded (incl. the signature) before invoking the signatureValidate() method?



Hope someone can help me here. Thanks.



Regards

GM
7 Replies

Avatar

Former Community Member
The last event to fire before giving control to the user is the Form Ready event. Try putting your code there and see if it will work (I do not think it will). I do not think you will be able to validate until the user has control.

Avatar

Former Community Member
Hi,

Verification can be done automatically by Acrobat. This is the option in acrobat menu Edit--Preferences--Security--Verify Signatures when the document is opened. Answer is not by script but I hope helps to you.



Asiye

Avatar

Former Community Member
Hi all,



Yup, Form:ready does not work. Actually, I think the last event to be fired is the Doc:ready event. That also doesn't work.



Asiye, I have tried that but some how the auto-verification just did not start when I open the document.



Is there a setTimeout( ) javascript equivalent for use in Adobe?



Thanks.

Avatar

Former Community Member
The setTimout is available app.setTimeOut() but any field reference must use the Acroform name and not the xfa name. All fields names must be fully pathed (i.e. for example form1[0].Page1[0].signatureField1[0]

Avatar

Former Community Member
Hi Paul,



Thanks for the reply. I tried using app.setTimeOut("myFunc()", 5000); ....but to no avail. The function just wasn't invoked.



I even tried:



app.setTimeOut("app.alert("test")",1000) and place this function in a button mousedown event. Upon clicking the button, nothing happens.



Is this the right way to use the setTimeOut function? Hope to hear from someone. Thanks lots.



Regards

GM

Avatar

Former Community Member
The setTimeOut is an AcroForm function so it does not know about XFA structures and commands. The myFunc() is a scripting object in XFA hence it does not know what to do. The app.alert test should work but I woudl change one set og quotes to single quotes so the command does not get confused. You can hit Ctrl-J to activate the javascript console to see if any errors where generated (only in Acrobat).

Avatar

Former Community Member
Here's a simple clock updated per second in a static text field.



----- form1::docReady - (JavaScript, client) ---------------------



timer1 = app.setInterval('xfa.form.form1.MYSO.doit();',1000);



MYSO is "title" given to a script object created by right-clicking on form1 and creating a script object. timer1 is not var-ed so that it's global.



----- form1.#variables[0].MYSO::MYSO - (JavaScript, client) --------



function doit()

{

//xfa.host.messageBox("doing it..");

var d = new Date();

var s = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();

xfa.form.form1.Content.StaticText1.rawValue = s;

}



Note, full path to wherever your static text field is (resolveNode may be too slow for timers), you can have it inserted for you by Ctrl-click on your field.



Kill timer (doesn't work switching from preview to design)



----- form1::docClose - (JavaScript, client) --------------------



app.clearInterval(timer1);



------------------



Ok that should get you going... btw, recursive setTimeOut seems unreliable and can die.



BTW, Adobe's usurpation of the javascript namespace is mind-boggling.

Should have direct access to javascript without the rewrap.



"everybody wants to rule the world..."