How to Stop PDF Form Email Submission Until Required Fields Are Complete
Question details
Prevent a PDF form from sending an email via a submit button when required fields are left empty.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up a fillable PDF form with a submit button that triggers an email, but needing to block the email if the user has not filled out all mandatory fields.
- Observed behavior
- The email submission action executes even when required fields (like text, dropdowns, and signatures) are empty, bypassing basic field requirements.
Before editing the button action, ensure you have the exact names of all required fields in your PDF form and the existing email submission script ready to be modified.
Use JavaScript to Validate Form Fields Before Emailing
Use a custom JavaScript action on the submit button to verify field values before triggering the email function.
By default, placing an email action directly on a submit button may bypass standard "Required" field checks. To enforce validation across all field types (including text, checkboxes, and signatures), you need a custom JavaScript script that halts the process if the fields contain their default or empty values.
Right-click the submit button in your PDF form, select 'Properties', and navigate to the 'Actions' tab.
From the 'Select Action' dropdown, choose 'Run a JavaScript', then click the 'Add' button to open the JavaScript Editor.
Write a script to loop through your required fields. Use a condition like `if (oField.valueAsString == oField.defaultValue)` to check if the field is empty. If it is, log the missing field and set a variable like `bProcess = false;`.
Relocate your email-sending code (such as `this.mailDoc(...)`) so that it sits inside an `if (bProcess)` block. This ensures the email is only sent when the validation flag confirms no required fields are empty.

Edit and Manage Fillable PDFs Easily with WPS Office
Handle fillable PDF forms effortlessly with WPS Office. Whether you are filling out forms, adding signatures, or managing required document workflows, WPS PDF provides a comprehensive and easy-to-use set of tools to edit and manage your PDFs natively.
- 1. Open Your PDF Form: Launch WPS Office and open the fillable PDF document you need to manage.
- 2. Fill and Edit Form Fields: Navigate to the 'Form' tab to interact with text fields, dropdowns, and checkboxes seamlessly.
- 3. Add Digital Signatures: Use the 'Sign' feature to quickly add and validate electronic signatures on required signature fields.
- 4. Save and Export: Once verified and complete, save your document or share it directly from the WPS interface.

Frequently Asked Questions
Can I make a PDF field required without using JavaScript?
Yes, you can check the 'Required' box in the General tab of a field's properties. However, if you are using a custom JavaScript button to send an email, this default setting may not prevent the script from running. You must include validation within your JavaScript code.
How do I validate a signature field in a PDF form?
Validating a signature field in JavaScript is similar to other fields. You check if the signature field's value is empty or matches its default unsigned state before allowing the email submission process to continue.
Why does my PDF email script run even if fields are empty?
If the email function (such as `mailDoc`) is placed before the validation check or outside the conditional success block in your script, it will execute unconditionally. Ensure the email code is placed exclusively within the section that only runs when validation passes.




