PDF Editing Issues

How to Add a Yes, No, Cancel Confirmation Dialog Before Emailing a PDF Form

Elise WilliamsElise Williams Oct 28, 2026 868 views

Question details

The user wants to prompt users with a Yes/No/Cancel confirmation dialog to verify if the file was saved correctly before emailing the submitted PDF form.

Add a Yes, No, Cancel Confirmation Dialog Before Emailing a PDF Form
Product
PDF
Device & OS
not provided
Scenario
Creating an interactive PDF form where the submit button conditionally handles document submission based on user confirmation.
Observed behavior
The form needs to email the completed PDF when 'Yes' is chosen, open the 'Save As' dialog when 'No' is chosen, and abort the operation entirely if 'Cancel' is clicked.
Before you start

Ensure you have a PDF editor that supports JavaScript execution and form field editing, and have your target recipient's email address ready to insert into the script.

Solution 1Recommended

Use JavaScript to Add a Confirmation Dialog to the Submit Button

By adding a custom JavaScript action to your form's submit button, you can trigger an alert dialog that handles the Yes, No, and Cancel logic effectively.

Advanced interactive PDF forms utilize JavaScript to execute conditional logic. You can use the app.alert method to display a dialog box with Yes, No, and Cancel buttons, and then route the user to the correct action based on their selection.

1
Create a form button

Open your PDF form in edit mode, navigate to the form creation tools, and draw a standard 'Button' field on the page where you want the submit action to occur.

2
Set the button action to JavaScript

Right-click the button and select Properties. Go to the 'Actions' tab, select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the action dropdown menu, and click 'Add'.

3
Implement the confirmation script

In the JavaScript editor, create a variable for the alert. Use code similar to: var response = app.alert('Did you save this file?', 2, 3, 'Confirmation'); to prompt the user. The '3' parameter specifies the Yes/No/Cancel button layout.

4
Add conditional execution logic

Below the alert, write an if-statement based on the response. If the response equals 4 (Yes), use this.mailDoc({cTo: 'recipient@example.com'}) to send it. If the response equals 3 (No), use app.execMenuItem('SaveAs'). For Cancel (2), simply do nothing.

5
Save and test

Close the JavaScript editor and properties panel, save the PDF document, and click the button to verify the dialog appears and functions correctly.

Use JavaScript to Add a Confirmation Dialog to the Submit Button
JavaScript Value Mapping: In Acrobat JavaScript, when using app.alert with nType 3, the returned values are: 4 for 'Yes', 3 for 'No', and 2 for 'Cancel'.

Manage Interactive PDF Forms Easily with WPS Office

WPS Office provides a robust suite of PDF tools, allowing you to edit PDF forms, add interactive buttons, and manage professional document workflows efficiently.

  1. 1. Open your PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
  2. 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to access interactive form field tools.
  3. 3. Add interactive fields: Insert a 'Push Button' or other form elements, and double-click to access its properties to configure actions.
  4. 4. Save securely: Once your form is complete, securely save the file and share it with your users.
Create, edit, and fill interactive PDF forms with an intuitive interface.Highly compatible with standard PDF formats including Adobe Acrobat files.Lightweight and fast, offering a smooth editing and reading experience across devices.
QA img-9

Frequently Asked Questions

What does the 'nType: 3' parameter do in PDF JavaScript?

In PDF JavaScript, the app.alert function uses the nType parameter to define the buttons displayed in the pop-up. Setting it to 3 automatically generates a dialog box with 'Yes', 'No', and 'Cancel' options.

Will this JavaScript code work on mobile PDF readers?

Custom JavaScript logic, especially scripts involving mailDoc or SaveAs menu items, is typically only supported on robust desktop PDF applications. Most mobile PDF readers restrict or completely ignore complex form scripts.

Why doesn't the email automatically send in the background when clicking 'Yes'?

For security reasons, the this.mailDoc function prepares the email by opening the user's default desktop email client (such as Outlook) with the PDF attached as a draft. PDFs cannot silently send emails in the background without user interaction.

How do I change the target email address in the submission script?

Locate the this.mailDoc line within your button's JavaScript code and replace the placeholder string within the cTo parameter. For example, change it to: cTo: 'admin@yourcompany.com'.