How to Require a Confirmation Checkbox Before Submitting a PDF Form
Question details
The user needs to validate a PDF order form to ensure a 'Confirm Order' checkbox is selected before the Submit button sends the email.

- Product
- PDF Form
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF order form where users must explicitly check a confirmation box prior to submission.
- Observed behavior
- The form should display a warning message if the confirmation checkbox is not selected, and only execute the email submission if the box is checked.
Ensure your PDF document already contains an interactive checkbox field and a standard button that you intend to use as the Submit button.
Add JavaScript Validation to the Submit Button
Use a custom JavaScript action on your submit button to check the state of the confirmation checkbox before executing the email function.
Interactive PDF forms allow you to use JavaScript to validate user input before triggering actions like emailing the document. By checking the string value of the checkbox field, you can conditionally send the email or display a warning alert to the user.
Enter form editing mode in your PDF editor, right-click the existing 'Submit Order' button, and select 'Properties'.
Navigate to the 'Actions' tab. Select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the 'Select Action' dropdown, and click the 'Add' button.
In the JavaScript editor, paste the following code: if (this.getField("ConfirmOrder").valueAsString == "Off") { app.alert("The Confirm Order checkbox must be selected before the order can be submitted.", 1); } else { this.mailDoc({cTo: "me@server.com", cSubject: "Subject line of the email", cMsg: "Email message body"}); }
Replace 'ConfirmOrder' in the script with the exact name of your checkbox field. Update the 'cTo', 'cSubject', and 'cMsg' parameters with your target email address, desired subject line, and message body. Click 'OK' to save.

Create and Edit Interactive PDF Forms with WPS Office
WPS Office offers a comprehensive built-in PDF editor that allows you to easily design, fill, and manage interactive PDF forms without requiring complex external tools.
- 1. Open your PDF file: Launch WPS Office and open your existing PDF form or create a new document.
- 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to view all interactive field options, including checkboxes and push buttons.
- 3. Edit and save: Use the intuitive interface to add or modify form fields, adjust their properties, and save your document for immediate use.

Frequently Asked Questions
Why does valueAsString return 'Off' for an unchecked box?
In PDF JavaScript, standard checkboxes default to an export value of 'Off' when they are unchecked, regardless of what their checked export value is (usually 'Yes' or 'On'). Checking valueAsString for 'Off' is the most reliable way to determine if a box is unselected.
How do I find the exact name of my checkbox field?
While in form editing mode, right-click the checkbox and select 'Properties'. The exact field name will be listed under the 'General' tab. You must use this exact name in your JavaScript code.
Can I validate multiple checkboxes before allowing submission?
Yes. You can chain multiple conditions in your JavaScript 'if' statement using the && (AND) operator. For example, check both fields to ensure they do not equal 'Off' before executing the this.mailDoc command.
Why isn't my submit button opening the email client after passing validation?
The mailDoc JavaScript function relies on the user's default desktop email client. If the user is opening the PDF in a web browser instead of a dedicated PDF reader, the browser's security settings will often block the action.




