How to Require At Least One PDF Form Field When a Checkbox is Selected
Question details
The user needs to set up conditional logic in a PDF form where selecting a specific checkbox makes filling out at least one of several text fields mandatory, rather than making all of them mandatory.

- Product
- Device & OS
- not provided
- Scenario
- Creating advanced conditional logic for interactive PDF forms where users only need to provide one of multiple requested details (e.g., either a phone number or an email address) when a specific option is checked.
- Observed behavior
- Using the standard 'required' property on the text fields forces users to fill out every single assigned field to submit the form, instead of satisfying the requirement by completing just one.
Before adding custom scripts, clearly map out your form's logic to determine exactly which fields should be linked to the checkbox and confirm whether the requirement is an 'AND' condition (all fields) or an 'OR' condition (at least one field).
Implement a Custom Validation Script for Form Submission
Bypass the built-in 'required' checkbox property and use a JavaScript validation script upon form submission to check if at least one of the target fields is filled.
The default 'required' property in PDF forms enforces that every marked field must be completed. To create an 'either/or' requirement where only one of several fields is needed, you cannot use the standard checkbox property. Instead, you must use custom JavaScript validation to evaluate the fields before the form is submitted.
Take note of the exact names of your trigger checkbox (e.g., 'Check1') and the target text fields (e.g., 'FieldA', 'FieldB'). Field names are case-sensitive.
Open the Properties of your target text fields, navigate to the General tab, and ensure the 'Required' box is unchecked so the default logic does not interfere.
Go to the properties of your Submit button, select the 'Actions' tab, choose 'Run a JavaScript' from the dropdown, and click 'Add'. Write a script that checks if 'Check1' is selected. If it is, evaluate 'FieldA' and 'FieldB'. If both are empty, trigger an alert (app.alert) and prevent the submission.

Create Interactive PDF Forms with WPS Office
WPS Office provides robust PDF editing tools, allowing you to create fillable forms, manage field properties, and design professional documents with ease. Build forms with text fields, checkboxes, and buttons that work seamlessly for your users.
- 1. Open your PDF in WPS Office: Launch WPS PDF and open the document you want to convert into an interactive fillable form.
- 2. Access the Form tools: Click on the 'Form' tab in the top ribbon to access the interactive form controls and editing options.
- 3. Insert checkboxes and text fields: Use the available form controls to insert your required checkboxes, text fields, and submit buttons onto the document page.
- 4. Customize field properties: Double-click any inserted field to adjust its appearance, set specific field names, and configure standard properties before saving your document.

Frequently Asked Questions
Why can't I just check the 'Required' box for multiple text fields?
Checking the 'Required' box on multiple form fields tells the PDF reader that every single one of those fields must contain data. Standard PDF properties do not natively support an 'at least one' (OR) logic, which is why a custom script is necessary.
Where is the best place to put the custom validation script in a PDF?
For submission validation, the script is typically placed in the Actions tab of the 'Submit' button. It should be set to trigger on the 'Mouse Up' event and must be placed above the actual form submission action so it can stop the process if validation fails.
Can I dynamically change field requirements when the checkbox is clicked?
Yes, you can add a 'Mouse Up' JavaScript action directly to the checkbox that changes the 'required' property of other fields dynamically (e.g., setting field.required = true). However, this still enforces that all newly required fields must be filled unless you specifically write an 'either/or' validation check.




