How to Hide an Unchecked Checkbox and Label After PDF Form Submission
Question details
The user wants to configure a PDF form so that if a checkbox is left unchecked, both the checkbox and its associated text label become hidden upon form submission.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Submitting a completed interactive PDF form where unselected options need to be hidden to clean up the final document's appearance.
- Observed behavior
- The user needs to implement a JavaScript action triggered by the submission event to dynamically change the display properties of specific form fields based on their checked state.
Ensure you know the exact field names of your checkbox and the text field acting as its label. Your PDF editor must support custom JavaScript for interactive form elements.
Add a JavaScript Action to the Submit Button
Configure the form's submit button to run a script that verifies the checkbox's state and hides it along with its label if it remains unchecked.
This method uses standard PDF JavaScript to alter field display properties. By attaching the script to the 'Mouse Up' action of your submit button, the PDF will instantly hide the specified fields right before the form data is processed.
Right-click the submit button in your PDF form and select 'Properties' from the context menu.
Navigate to the 'Actions' tab. Select 'Mouse Up' in the 'Select Trigger' dropdown, choose 'Run a JavaScript' from the 'Select Action' menu, and click 'Add'.
In the JavaScript editor, input the following code: if (this.getField("Checkbox1").valueAsString == "Off") { this.getField("Checkbox1").display = display.hidden; this.getField("Text1").display = display.hidden; }
Replace "Checkbox1" with the actual name of your checkbox field and "Text1" with the name of the text field that serves as your label. Click 'OK' and close the properties window to save your changes.

Edit and Manage Interactive PDF Forms Easily with WPS Office
WPS Office offers a comprehensive suite of PDF tools, allowing you to seamlessly create, edit, and fill interactive PDF forms, including managing field properties and optimizing form layouts.
- 1. Open Your PDF in WPS: Launch WPS Office and open your PDF form using the built-in PDF editor.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to access tools for checkboxes, text fields, and buttons.
- 3. Modify Form Controls: Double-click any form field to instantly adjust its appearance, properties, and actions to suit your form submission needs.

Frequently Asked Questions
Why isn't the script hiding my text label?
This commonly occurs if the label is written as static text on the PDF rather than being formatted as an interactive text form field. Ensure you create a specific 'Text Field' for the label so the JavaScript can target and hide it.
Can I hide multiple checkboxes at once?
Yes. You can extend the JavaScript by adding additional 'if' statements or using a loop to check multiple checkboxes, ensuring you reference the exact field name for each checkbox and corresponding label.
How do I make the fields visible again if the user needs to correct the form?
You will need to trigger a reset script. You can add a 'Reset Form' button with a JavaScript action that sets the display property back to visible: this.getField("Checkbox1").display = display.visible;




