How to Validate Required Fields Before Emailing a PDF Form
Question details
The user wants to ensure all required fields in a PDF form are completely filled out correctly before allowing the end-user to submit the form via email.

- Product
- Adobe Acrobat Pro
- Device & OS
- not provided
- Scenario
- Submitting a completed PDF form via email while ensuring no required data fields are left blank by the user.
- Observed behavior
- The form needs to trigger a validation script, display a warning prompt if fields are missing, request final confirmation, and only launch the default email client when validation is entirely successful.
Ensure you have a professional PDF editor that supports JavaScript execution and advanced form field properties, such as Adobe Acrobat Pro or WPS Office PDF.
Add a Custom JavaScript Validation Action to the Submit Button
Use custom JavaScript attached to a button's 'Mouse Up' trigger to check empty fields, prompt the user, and launch the email client upon success.
By binding a JavaScript action to the form's submit button, you can programmatically loop through all required fields. If any are empty, the script prevents submission and alerts the user. If all validations pass, it prompts for confirmation before executing the mailForm command.
Open your PDF file in Acrobat Pro or your advanced PDF editor and enter the 'Prepare Form' or 'Form Edit' mode.
Right-click the Submit button on your form, select 'Properties' from the context menu, and navigate to the 'Actions' tab.
Under 'Select Trigger', choose 'Mouse Up'. Under 'Select Action', select 'Run a JavaScript', then click the 'Add' button.
In the JavaScript Editor window, insert your logic to loop through required fields. Use an 'if' statement to trigger an alert using 'app.alert' if any field is empty, prompting the user to complete the form.
Add the success condition to prompt a final confirmation: var result = app.alert({cMsg: 'Send the completed form?', cTitle: 'Confirm Submission', nIcon: 2, nType: 2});. Below that, add: if (result == 4) { this.mailForm({bUI:true, cTo:'recipient@example.com', cSubject:'Completed form'}); } to launch the email client.

Use WPS PDF to Create and Manage Interactive PDF Forms
WPS Office provides robust PDF editing capabilities, allowing you to easily design interactive forms, add push buttons, and handle form submission settings without complicated coding.
- 1. Open your PDF Document: Launch WPS Office and open the PDF form you want to edit.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form controls.
- 3. Insert Interactive Elements: Click 'Push Button' or 'Text Field' and drag on the document to place your form elements.
- 4. Configure Properties: Double-click the button to open its Properties. Under the Actions tab, you can set it to submit a form or execute custom actions.

Frequently Asked Questions
Why doesn't the email client open when I click the validated submit button?
The email client may fail to open if the user clicks 'No' on the confirmation prompt, if there is a syntax error in your JavaScript code, or if the user's operating system does not have a default email application properly configured.
Can I validate specific formatting like email addresses or phone numbers using this method?
Yes. You can incorporate Regular Expressions (Regex) within your JavaScript validation loop to verify that the inputted text matches specific patterns (like a valid email address) before the script proceeds to the mailForm function.
How do I mark a field as required without writing any custom JavaScript?
In most PDF editors, you can right-click the form field, select Properties, navigate to the General tab, and simply check the 'Required' box. However, enforcing a strict block on email submission often still requires custom JavaScript, as basic required properties might be bypassed depending on how the submission is triggered.




