Copy link to clipboard
Copied
I have a PDF form which require signatures at different levels.
When the form is signed at the first level, then previous fields must become read-only.
This can easely be done under properties > Signed, then 'MArk as read-only > select the fields to include/exclude from becomming read only.
My challange however is that I want to populate a date field at the same time. I am therefor using the 3rd option to execute a js script.
I am asked where I want to save the signed form.
Signature is applied and the specified fields are read-only on screen.
When I close the form I am prompted to save any changes.
- If I choose save, all is fine.
- If I choose cancel, then the form has the signature applied, but all fields are editable.
I am thinking that the signature is applied and that bit is saved, but the script is executed after that part and not saved.
I also have a 'mouse-down' script in the signature field which just shows an alert that fields will be looked if signing the form.
I tried to place the script in the mnouse down/up location, but that means, if the user clicks on the signature field, gets the alert and decides not to sign the document (cancels out from the signature), then the fields are locked already.
In short, it there a way to populate the date field and lock the fields when the form is signed and saved.
Current code under Properties > Signed
// JavaScript code to add the date at signing time
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");
f.value = signingTime;
// Look specific fields when digital signature is applied
this.getField("Date1").readonly = true; // Lock signature date field
this.getField("Check Box1").readonly = true;
this.getField("Facility").readonly = true;
this.getField("Address").readonly = true;
this.getField("Account Name").readonly = true;
this.getField("Bank Name").readonly = true;
this.getField("Bank Branch").readonly = true;
this.getField("Bank BSB").readonly = true;
this.getField("Bank Account Nr").readonly = true;
Many thanks for any suggestions and pointers.
Copy link to clipboard
Copied
No, not really. The script is executed after the file is saved by the user, so any changes made to the document have to be saved for them to "stick". You can prompt the user to save the file again, but you can't force them to do so.
One thing you can do, though, is to hide the signature field and use a "Prepare for Signature" button to do all of these changes (making the fields read-only, populate the date field, etc.), and then make the signature field visible for the user to sign.
Copy link to clipboard
Copied
Thanks for your reply Try67,
I think I found a solution for my situation.
I use a 'mouse-down' script for the 'Alert' about fields being locked, and moved the current date script to that same action.
So now when the user clicks on the signatore field, they get a n 'alert' and the date field is populated.
Under the Properties > Signed, as I no longer need to run the script there, I can use the second option and select the fields I want to lock.
The flow now goes;
Click signature field > get alert > date populated > digital signature pop-up > enter password > choose save location. Done.
IF the user cancels at the signature stage, the date is already populated, but not locked and will be overwriten nect time the signature fieds is clicked again.