How to Make PDF Form Fields Editable Based on Checkbox Selection
Question details
Dynamically enable, disable, or highlight specific fields in a KYC PDF form based on whether a 'single' or 'joint' account checkbox is selected.

- Product
- PDF Form Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive KYC PDF form where the required fields change dynamically depending on the account type selected by the customer.
- Observed behavior
- Target form fields need to update their read-only and appearance properties automatically upon checkbox selection, while properly handling required fields that overlap between account types.
Ensure that your PDF editing software supports JavaScript for interactive form fields, as conditional logic requires scripting to alter field properties dynamically.
Use JavaScript on Checkbox MouseUp Event
Attach a custom JavaScript action to the checkbox's MouseUp event to change the read-only and appearance properties of your target fields.
By utilizing a custom JavaScript action, you can define arrays of field names for each customer type (e.g., single account vs. joint account). When the checkbox is clicked, the script evaluates the selection, enables the appropriate fields, and disables the others.
Open your document in Form Editing mode, right-click the target checkbox, and select 'Properties' from the context menu.
Navigate to the 'Actions' tab in the Properties dialog. Choose 'Mouse Up' as the trigger, select 'Run a JavaScript' from the action drop-down list, and click 'Add'.
In the JavaScript editor, enter the code that defines your field arrays. Use logic to set the 'readonly' property to false for required fields and true for disabled ones based on the checkbox state.
Click 'OK' to save your script and close the Properties dialog. Exit form editing mode to test the checkbox and ensure the target fields become editable as intended.

Easily Edit and Fill PDF Forms with WPS Office
WPS Office offers a comprehensive PDF toolkit that allows you to easily view, manage, and fill interactive PDF forms. Whether you need to handle checkboxes, text fields, or drop-down menus, WPS PDF makes document processing smooth and intuitive.
- 1. Open your PDF Document: Launch WPS Office and open the interactive PDF form you need to process.
- 2. Navigate to Form Filling: Simply click on the interactive fields, such as checkboxes or text boxes, to input your data directly.
- 3. Manage Form Fields: Use the PDF editing toolkit in the top ribbon to make adjustments to your document structure if you are working with premium editing features.
- 4. Save and Export: Once your form is filled, click 'Save' or export it directly to share with your clients or colleagues.

Frequently Asked Questions
Can I make fields conditionally required instead of just editable?
Yes. Within your JavaScript code, you can target a field's 'required' property (e.g., field.required = true) in addition to modifying its 'readonly' status based on the checkbox selection.
Why aren't my conditionally enabled PDF form fields updating immediately?
This is often due to the trigger event used. Ensure your script is set to run 'On Mouse Up' rather than 'On Mouse Down'. The Mouse Up event guarantees that the checkbox's state has fully registered before the script executes.
Do these conditional scripts work in all PDF readers?
No. These scripts rely on the PDF viewer's JavaScript engine. Standard applications like Adobe Acrobat or fully-featured PDF editors process them correctly, but simple browser extensions or basic mobile PDF readers might not execute the scripts.
How do I highlight the editable fields automatically?
In your JavaScript, alongside changing the readonly status, you can modify the 'fillColor' property of the field. Setting the fill color to a light yellow or returning it to transparent will visually indicate that the field is now editable.




