PDF Editing Issues

Keep an Acrobat Calculated Date Field Blank When the Source Is Empty

Adam DavisAdam Davis Nov 19, 2026 869 views

Question details

Keep a calculated PDF date field blank when its source date field is empty.

Keep an Acrobat Calculated Date Field Blank When the Source Is Empty
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form calculates a date one day after a source date and formats the result as mm/dd/yy.
Observed behavior
Clearing the source date can cause the calculated field to display an invalid date such as 01/00/00.
Before you start

Open the PDF in Acrobat and identify the source and calculated field names in Prepare a Form. The example below uses prodDate as the source field and adds one day.

Solution 1Recommended

Check the source field before calculating the date in Acrobat

Use a custom calculation script to clear the result when the source date is empty.

Test the source field's text before creating a Date object. An invalid Date object still exists, so checking the object alone does not reliably detect an empty source.

1
Open the form editor

In Acrobat, open the PDF and select All tools > Prepare a form. Select the calculated date field and open its Properties.

2
Edit the calculation script

In the field's Properties, open the Calculate tab, select Custom calculation script, and click Edit.

3
Check the source value

Replace the calculation script with the following, changing prodDate if your source field has a different name: var dateString = this.getField("prodDate").valueAsString; if (dateString == "") { event.value = ""; } else { var date = new Date(dateString); date.setDate(date.getDate() + 1); event.value = util.printd("mm/dd/yy", date); }

4
Save and test the form

Click OK to save the script, close Properties, and save the PDF. Enter a valid source date to check the next-day result, then clear the source field and confirm that the calculated field is blank.

Check the source field before calculating the date in Acrobat
Check the date format: The script handles an empty source value, but it does not validate nonempty dates. Test it with the source field's date format and Acrobat version, since JavaScript date parsing can vary.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easier to move existing files into your workflow. Use Acrobat to edit the Acrobat-specific JavaScript calculation described above.

Open and work with PDF documents alongside other filesCompatible with Microsoft Office formats, including DOCX, XLSX, and PPTXUse a familiar interface to move between documents and spreadsheetsFree and lightweight for everyday office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does the calculated field show 01/00/00 after I clear the source date?

The script may be trying to create and format a Date from an empty string. Check the source field's valueAsString first and set event.value to an empty string when it is blank.

Where do I add the calculation script in Acrobat?

Open All tools > Prepare a form, open the calculated field's Properties, and select Calculate > Custom calculation script > Edit.

What if my source field is not named prodDate?

Replace prodDate in this.getField("prodDate") with the exact source field name shown in Prepare a Form.

Does the script also handle invalid dates entered by users?

No. It handles an empty source field but does not validate nonempty input. Test the source field's date format and add validation if users can enter invalid dates.