PDF Editing Issues

Fix Acrobat Custom Calculation Script Not Displaying a Result

Adam DavisAdam Davis Oct 28, 2026 868 views

Question details

A custom JavaScript calculation designed to calculate the number of days between two date fields fails to display any result in the target field.

How to Fix Acrobat Custom Calculation Script Not Displaying Results
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating an interactive PDF form where a specific field is supposed to automatically calculate and display the lead time based on two input dates.
Observed behavior
The calculation field remains entirely blank despite the date formats and field names appearing correct. Additionally, clearing one of the date fields might cause the target field to retain an outdated value.
Before you start

Ensure that you have sufficient permissions to edit the PDF form and that JavaScript is enabled in your PDF viewer's preferences (Edit > Preferences > JavaScript).

Solution 1Recommended

Add an 'Else' Condition and Verify Script Placement

Update the calculation script to handle empty date fields properly and ensure it is placed in the exact Custom Calculation Script area.

When writing custom JavaScript for PDF date calculations, the script will often fail to update or display results if one of the referenced fields is empty. By defining an 'else' condition, you force the field to clear itself rather than breaking the script or holding an old value.

It is also critical to confirm that the script is applied directly to the target calculated field, rather than document-level scripts.

1
Open Field Properties

Open your PDF in 'Prepare Form' mode, right-click the target calculated lead-time field, and select 'Properties'.

2
Locate the Custom Calculation Area

Navigate to the 'Calculate' tab, choose the 'Custom calculation script' radio button, and click the 'Edit' button.

3
Append the Else Condition

At the very end of your existing calculation code, add the line: `else event.value = "";`.

4
Save and Test

Click 'OK' to save the script, close the properties window, and test the form by entering and clearing dates in the source fields.

Add an 'Else' Condition and Verify Script Placement
Verification Tip: Double-check the exact field names in your script against the 'Fields' pane. Watch out for auto-generated suffixes like '_af_date' which might cause reference errors.
Advanced PDF Form Editing

Effortlessly Manage and Edit PDF Forms with WPS Office

Bypass complex script debugging by using WPS Office's intuitive PDF editing tools. WPS Office provides a streamlined, user-friendly interface to manage interactive form fields, edit PDF text, and handle daily document workflows with ease.

  1. 1. Install WPS Office: Download and install the free version of WPS Office from the official website.
  2. 2. Open Your PDF: Launch WPS PDF and open the interactive form you want to edit.
  3. 3. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to easily add, modify, or format text fields and checkboxes without writing complex code.
Easily insert, edit, and manage interactive PDF form fieldsFully compatible with Microsoft Office formats (Word, Excel, PowerPoint) and standard PDFsLightweight, fast execution on Windows, Mac, and mobile devicesFree to download with premium features for advanced document processing
microsoft office alternative - wps office

Frequently Asked Questions

Why does my calculated date field show an incorrect format?

The target field needs to know how to display the calculated result. Right-click the field, select 'Properties', go to the 'Format' tab, and ensure the format category is correctly set (e.g., 'Number' for days, or 'Date' if outputting a specific date).

How do I find the exact field name Acrobat generated?

In 'Prepare Form' mode, look at the 'Fields' pane on the right-hand side of your screen. This list displays the exact, actual names of all fields in the document, including any system-added suffixes like '_af_date' that your script must reference exactly.

Why does the calculation not update when I change a field value?

This usually happens due to an incorrect calculation order, especially if multiple fields depend on each other. You can fix this by going to the 'More' option (or the settings menu) in the Prepare Form toolbar and selecting 'Calculate Order' to arrange them logically.