How to Validate Selected PDF Form Fields With a Custom Submit Button
Question details
The user needs to configure a secondary submit button in a PDF form that only validates a specific subset of fields (Name, Employee Number, and Date) prior to sending the form for manager approval.

- Product
- Device & OS
- not provided
- Scenario
- Setting up a PDF form for a multi-step manager approval workflow where different submit buttons require different fields to be validated.
- Observed behavior
- The default submit action validates all fields marked as 'required', which prevents the secondary button from executing if unneeded fields are left blank. A custom solution is required to bypass global validation and check specific fields.
Ensure you have access to a PDF editor that supports adding JavaScript to interactive forms, and write down the exact case-sensitive field names for the fields you want to validate.
Use JavaScript to Validate Specific Fields Before Submission
Assign a custom JavaScript action to your secondary submit button to check the specific fields and execute the submission only if those fields contain data.
Using a custom JavaScript action allows you to bypass standard PDF required field validation. By doing this, you can target only the fields necessary for this specific workflow step without making the fields globally mandatory.
In your PDF form editing mode, right-click the secondary manager-approval submit button and select 'Properties'.
Go to the 'Actions' tab. Select 'Mouse Up' as the trigger event, and choose 'Run a JavaScript' from the 'Select Action' dropdown menu.
Click 'Add' and input a script that checks your specific fields. Define an array with your field names (e.g., ['Name', 'Employee Number', 'Date']), loop through them to check if 'this.getField(fieldName).value' is empty, and display an alert message if any required field is missing.
In the same script, add a condition that executes 'this.submitForm({cURL: "mailto:manager@example.com", cSubmitAs: "PDF"})' only if all the checked fields contain valid data. Click OK to save and then test your button.

Easily Manage Interactive PDF Forms with WPS Office
WPS Office provides robust PDF editing capabilities, allowing you to fill, sign, and manage interactive forms. Streamline your document workflows effortlessly with a lightweight and user-friendly interface.
- 1. Open PDF in WPS: Launch WPS Office and open your interactive PDF document.
- 2. Access Form Filling Tools: Navigate to the 'Fill & Sign' or Form tab in the top ribbon to interact with the form controls.
- 3. Input Data Seamlessly: Click on the designated text boxes, checkboxes, or dropdowns to enter the required manager approval information.
- 4. Save and Distribute: Save your completed interactive PDF form to securely share with your team or manager.

Frequently Asked Questions
Can I validate different fields with multiple submit buttons in the same PDF?
Yes. To achieve this, do not mark the fields as 'required' in their standard properties. Instead, use custom JavaScript on each separate submit button to validate only the fields relevant to that specific button's function before executing the submit command.
Why isn't my JavaScript validation script working?
Common issues include typos in the exact field names (JavaScript is case-sensitive), syntax errors in the code loop, or PDF viewer settings that have disabled JavaScript execution for security reasons.
Does WPS Office support filling out interactive PDF forms?
Yes, WPS Office fully supports filling, saving, and printing interactive PDF forms, making it an excellent tool for handling documents with text fields, checkboxes, dropdowns, and basic submit actions.




