How to Prevent an Acrobat PDF Form from Locking if Email Submission is Canceled
Question details
The user needs to stop a fillable PDF form from permanently locking its fields when an email submission process is initiated but subsequently canceled.

- Product
- Adobe Acrobat Fillable PDF
- Device & OS
- not provided
- Scenario
- Submitting a fillable PDF form via a custom 'Email and Save As' button that utilizes a locking script.
- Observed behavior
- The form fields lock immediately when the submit button is clicked. If the user cancels the email action, the form remains locked and no further corrections can be made.
Before modifying your form scripts, ensure you have a backup copy of the original fillable PDF and access to Adobe Acrobat Pro or a compatible PDF editor with JavaScript support.
Adjust Script Execution to Lock Fields After Submission
Modify the JavaScript attached to your submit button so that the form locking mechanism is triggered only after the email or save operation completes.
Because Adobe Acrobat JavaScript does not reliably provide a cancellation callback for email commands, placing the locking script before the email command guarantees the form will lock regardless of the email's success.
To resolve this, you must change the execution order so that the form submits first. Note that even with this change, testing is required as Acrobat's behavior can vary between versions.
Open your PDF document in Adobe Acrobat Pro and select the 'Prepare Form' tool from the right-hand pane.
Right-click the 'Email/Submit' button on your form and choose 'Properties' from the context menu.
Navigate to the 'Actions' tab, select the 'Run a JavaScript' action assigned to the Mouse Up event, and click 'Edit'.
Locate the code that sets the fields to read-only (e.g., this.getField("FieldName").readonly = true). Move this block of code so it appears sequentially after your doc.mailDoc() or app.mailMsg() commands.

Implement a Separate Lock and Submit Workflow
Separate the locking mechanism from the email submission to give users full control over when the form is finalized and prevent accidental lockouts.
Easily Manage and Share Fillable PDFs with WPS Office
Avoid complex JavaScript locking issues by using WPS Office to easily fill, protect, and share PDF forms. WPS Office provides an intuitive interface for managing PDF documents, allowing you to secure files without relying on convoluted coding.
- 1. Open your PDF Form: Launch WPS Office and open your fillable PDF document.
- 2. Fill the Form Fields: Navigate to the 'Form' tab to interact with, type into, or select the necessary fields.
- 3. Protect the Document: Once completed, go to the 'Protect' tab to add a restriction password, effectively locking the document from further edits without the need for custom scripts.
- 4. Share via Email: Click 'Menu' and select 'Share' or 'Email' to safely attach the finalized, protected document to your default mail client.

Frequently Asked Questions
Why does my Acrobat form lock before the email is actually sent?
If the JavaScript attached to the submit button executes the field-locking command before the email command, the form locks immediately upon clicking. If the user then cancels the email draft, the script does not automatically reverse the lock.
Can I unlock the PDF form if I accidentally canceled the email?
Once fields are set to read-only via a script, you cannot unlock them as a standard user unless you close the document without saving and reopen it. Only a user with Acrobat Pro can manually change the field properties back to editable.
Does Adobe Acrobat's JavaScript API know if an email is canceled?
No, Adobe Acrobat's JavaScript API does not consistently return a success, failure, or cancellation callback for email actions like mailDoc(). This makes it very difficult to script an automatic 'unlock on cancel' function.
How do I make a field read-only using PDF JavaScript?
You can use the script this.getField("FieldName").readonly = true; to lock a specific field. To lock all fields, you would typically use a loop that iterates through all fields in the document and applies this property.




