PDF Editing Issues

How to Validate Full and Partial Dates in Acrobat PDF Forms

John WilsonJohn Wilson Nov 3, 2026 868 views

Question details

The user needs a method to validate both complete dates (such as dd-mmm-yyyy) and partial dates (such as mmm-yyyy) within an Acrobat PDF form.

How to Validate Full and Partial Dates in Acrobat PDF Forms
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating or configuring an interactive PDF form where users can input either a specific day or just a month and year.
Observed behavior
Built-in Acrobat JavaScript date utilities fail to validate partial dates because a month and year without a day is not recognized as a valid date string.
Before you start

Ensure you have access to the 'Prepare Form' tool in your PDF editor and that you have permissions to edit form field properties and JavaScript actions.

Solution 1Recommended

Implement Custom JavaScript for Date Validation

Use a custom JavaScript script to prepend a dummy day to partial dates, allowing the system to validate both full and partial date formats successfully.

Acrobat's built-in date validation requires a specific day to recognize a date string. To bypass this limitation for partial dates (mmm-yyyy), you can write a script that temporarily adds '01-' to the input. This lets the system check if it is a valid month and year combination without breaking standard full-date validation.

1
Open the Prepare Form tool

Open your PDF document in Adobe Acrobat, navigate to the right-hand pane, and select the **Prepare Form** tool to enter form editing mode.

2
Access Field Properties

Right-click on the date text field you want to validate and choose **Properties** from the context menu.

3
Set up Custom Validation

Go to the **Validate** tab in the Properties window. Select the **Run custom validation script** radio button, and click the **Edit** button.

4
Enter the JavaScript Code

In the JavaScript Editor, enter the following code to validate the dates: `var newValue = event.value; if (newValue != "") { if (util.scand("dd-mmm-yyyy", newValue) == null && util.scand("dd-mmm-yyyy", "01-" + newValue) == null) { app.alert("Enter a date in dd-mmm-yyyy or mmm-yyyy format.", 1); event.rc = false; } }`

5
Save and Test

Click **OK** to close the JavaScript Editor, then click **Close** on the Properties dialog. Exit form editing mode and test the field by typing a partial date like 'Jan-2024'.

Implement Custom JavaScript for Date Validation
Validation Logic Explained: The script first checks if the input is a valid full date. If that fails (returns null), it adds '01-' to the input and checks again. If both checks fail, it rejects the input.
WPS PDF Editor

Easily Edit and Manage PDF Forms with WPS Office

While advanced JavaScript date validation can be complex to set up, WPS Office offers a user-friendly PDF editor that makes creating, filling, and managing standard PDF forms straightforward and highly efficient.

  1. 1. Launch WPS PDF: Open WPS Office on your computer and click the **PDF** icon on the home screen to launch the built-in PDF tool.
  2. 2. Open Your PDF Form: Click **Open PDF** and browse your computer to select the fillable form document you need to work on.
  3. 3. Use Form Tools: Navigate to the **Form** or **Fill & Sign** tab on the top ribbon. Here you can easily add text, insert interactive fields, or place an electronic signature without needing JavaScript.
  4. 4. Save and Share: Once your form is filled or edited, click **Menu** > **Save** to keep your document perfectly compatible with all standard PDF readers.
Easily fill out, sign, and manage interactive PDF forms without writing complex scriptsInsert text, checkboxes, and date fields intuitively using the Form tabFully compatible with Microsoft Office formats (Word, Excel, PowerPoint) and standard Adobe PDF filesLightweight architecture ensures fast loading even for large, form-heavy documents
microsoft office alternative - wps office

Frequently Asked Questions

Why does built-in validation reject 'mmm-yyyy' as a valid date format?

Built-in date functions like `util.scand` require a specific day, month, and year to successfully parse a string into a Date object. A string with only a month and year lacks the necessary day parameter, causing the validation to fail and return null.

Can I apply this validation script to multiple date fields at once?

Yes. You can copy and paste the custom validation script into the Validation tab of each date field's Properties dialog. Alternatively, you can define a document-level JavaScript function and simply call that function from each field's validation trigger.

What happens if a user enters a completely invalid date format?

If the input does not match the 'dd-mmm-yyyy' format or the 'mmm-yyyy' format (after the script prepends '01-'), both checks will return null. The script then triggers an alert box warning the user and sets `event.rc = false` to clear and reject the invalid input.

Does WPS PDF support filling out interactive form fields?

Yes, WPS PDF supports interactive form fields. You can easily open standard PDF forms, click into text fields to type your answers, toggle checkboxes, and insert electronic signatures using the WPS PDF editor tools.