Expand my Community achievements bar.

How to make signature field to be required field?

Avatar

Level 1
I make an PDF form that contain text fields, signature field and submit button. Some text fields on form are required field. User can't send form by email until requred fields are empty.

I want to do that user can't send form by email until signature fields is is empty.



Is it possible?



I guess there is some JavaScript trick to do it.
3 Replies

Avatar

Level 1
I've found a solution.



In the "initialization" event script write this:



this.mandatory = 'error'

this.mandatoryMessage = 'Please sign the document';

Avatar

Former Community Member
Hi-

I am not familiar with using script. Can you help me with this same problem. Step-by-step?

Avatar

Former Community Member
I was able to use a similar technique to successfully require a signature field. The problem with using just the above mentioned script is the signature field never realizes it has been signed and thus, never removes the requirement. You must determine the signing action manually and remove the requirement manually for the entire process to work. All of my script is written in FormCalc script so make sure you have this selected in the script editor.



Place the following code in the "initialize" event of the signature field:



$.validate.nullTest = "error"



Now change to the "layout:ready" event of the signature field and apply the following:



var signature1Blank = $.saveXML();



This creates a 'footprint' of the signature field pre-signing. The goal here is to determine when the field gets 'signed'.



The final step is to place the following piece in whatever action makes the most sense for your form. Mine uses a submit button to post the xml to a listener page so I put it in the 'mouseDown' event of my submit button:



if (form1.#subform[2].SignatureField1.saveXML() <> signature1Blank) then

form1.#subform[2].SignatureField1.validate.nullTest = "disabled"

endif



As you can see, the script compares the current XML 'footprint' of the signature with the 'footprint' taken upon loading the form. If they are different, the field must've been signed and we can remove the requirement thus allowing the submittal to proceed.