PDF Editing Issues

How to Return an Empty String for an Unchecked PDF Checkbox

Ayan MasoodAyan Masood Nov 2, 2026 868 views

Question details

The user wants a PDF form calculation script to return an empty string or a specific numeric value when a checkbox is unchecked, bypassing the default 'Off' value.

How to Return an Empty String Instead of 'Off' for Unchecked PDF Checkboxes
Product
Adobe Acrobat / PDF Editors
Device & OS
not provided
Scenario
Creating or modifying custom JavaScript calculations for interactive PDF form checkboxes.
Observed behavior
When a PDF form checkbox is unchecked, the script evaluates its state as the string 'Off', which interferes with mathematical additions and formatting.
Before you start

Ensure you have access to the form editing tools and JavaScript properties within your PDF editor. Familiarity with basic JavaScript syntax is recommended before modifying custom form calculations.

Solution 1Recommended

Use JavaScript to Explicitly Test for the 'Off' Value

Modify your custom calculation script to explicitly check if the export value is 'Off' and replace it with an empty string or your required numeric value.

By default, standard PDF forms assign the literal string value 'Off' to unchecked checkboxes. To prevent this string from displaying or breaking calculations, you must intercept the value and conditionally return an empty space or a number.

1
Open Field Properties

Open your PDF document in Form Editing mode. Right-click the target calculation text field (where you want the result to appear) and select 'Properties'.

2
Access Custom Calculation Script

Navigate to the 'Calculate' tab inside the Properties window. Select the 'Custom calculation script' option and click 'Edit' to open the JavaScript editor.

3
Input the Conditional Logic

Enter the following script to test the checkbox state: var check = this.getField('Check Box4').valueAsString; event.value = (check == 'Off') ? '' : 2; This assigns an empty string if unchecked, or the number 2 if checked.

4
Save and Test

Click 'OK' to save the script, then 'Close' the properties dialog. Exit Form Editing mode and toggle your checkbox to verify it returns an empty string instead of 'Off'.

Use JavaScript to Explicitly Test for the 'Off' Value
Match Field Names: Make sure to replace 'Check Box4' with the exact name of your checkbox, and replace '2' with the export value you configured for the checked state.

Create and Edit Interactive PDF Forms Seamlessly with WPS Office

WPS PDF provides powerful form building and editing tools, enabling you to insert checkboxes, customize export values, and manage PDF documents effectively without advanced coding.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document. Navigate to the 'Form' tab located in the top ribbon.
  2. 2. Insert Form Controls: Click on 'Check Box' or 'Text Field' from the toolbar to place interactive elements anywhere on your document.
  3. 3. Customize Field Properties: Double-click the inserted form field to adjust its properties, name, and export values, ensuring the form behaves exactly as you need.
Easily manage interactive PDF form fields, including checkboxes, text boxes, and dropdowns.Fully compatible with standard PDF documents and Microsoft Word, Excel, and PowerPoint formats.Lightweight, cross-platform PDF editor with a clean and familiar user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF form checkbox return 'Off'?

By default, the PDF specification assigns the hardcoded string value 'Off' to any checkbox or radio button that is not selected. This standard behavior ensures the PDF reader knows the precise toggle state of the element.

Can I change the default 'Off' value in the PDF checkbox properties?

No, the 'Off' state is an inherent part of standard PDF form behavior. While you can change the custom export value for the 'checked' state, you must use a custom JavaScript calculation to alter the output of the 'unchecked' state.

How do I test if a PDF checkbox is checked using JavaScript?

You can test its state by evaluating its value as a string. For example, using `if (this.getField('MyCheckBox').valueAsString != 'Off')` verifies that the checkbox is currently checked and actively using its assigned export value.