How to Validate That an End Date Is After a Start Date in Adobe Acrobat
Question details
The user wants to set up a validation rule in an Adobe Acrobat fillable PDF so that the End Date entered by a respondent is strictly after the Start Date.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing a fillable PDF form with date fields that require logical validation.
- Observed behavior
- Setting up custom validation logic to prevent users from entering an End Date that occurs before or on the same day as the Start Date.
Ensure your PDF form already contains two properly formatted text fields designated for dates, specifically named for the Start Date and End Date, and that both share the exact same date format setting.
Add Custom JavaScript Validation to the End Date Field
Use a custom JavaScript snippet in the End Date field properties to compare the two date values and reject invalid inputs automatically.
Adobe Acrobat requires custom JavaScript to compare the values of two different form fields. By adding a script to the End Date field, Acrobat will automatically verify the input against the Start Date field every time a user fills it out.
The script converts both date strings into JavaScript Date objects so they can be mathematically compared. If the validation fails, the input is rejected.
Open your document in Acrobat, navigate to the Tools menu, and select 'Prepare Form' to enable form field editing.
Right-click on your End Date field and select 'Properties' from the context menu. Navigate to the 'Validate' tab.
Select the 'Run custom validation script' radio button and click the 'Edit' button to open the JavaScript editor window.
Write a script that retrieves the Start Date value using 'this.getField("YourStartDateField").value'. Convert both this value and the current field's value (event.value) to Date objects. Compare them, and if the End Date is less than or equal to the Start Date, set 'event.rc = false' and optionally trigger an 'app.alert()' message.
Click 'OK' to close the editor, then close the Properties dialog. Save your PDF and enter test dates to ensure the validation rejects earlier End Dates correctly.

Edit, Fill, and Manage PDF Forms with WPS Office
While complex JavaScript validation requires specialized form-builder tools, WPS Office provides a powerful, lightweight, and user-friendly PDF editor to effortlessly create, fill, sign, and manage PDF documents on any device.
- 1. Open WPS PDF: Launch WPS Office and open your interactive PDF form.
- 2. Access Form Tools: Navigate to the 'Form' or 'Fill & Sign' tab on the top ribbon.
- 3. Input Data: Click directly on the highlighted text fields, including Start and End dates, to input your data easily.
- 4. Save and Share: Save the completed form locally or export it as a flattened PDF to securely share your information.

Frequently Asked Questions
Why isn't my JavaScript date validation working in Acrobat?
This usually happens if the date formats specified in the 'Format' tab do not match exactly between the Start Date and End Date fields, or if the exact field names referenced in your JavaScript do not match the actual names of your form fields.
Can I validate dates in a PDF without using custom JavaScript?
No, Adobe Acrobat requires custom JavaScript for comparing two distinct fields. The built-in standard validation only checks if a single field matches a specific format or falls within a hardcoded numerical range.
How do I show an error message when the wrong date is entered?
Within your custom validation script, you can use the 'app.alert("Your error message here");' function right before setting 'event.rc = false;'. This triggers a pop-up warning the user that their End Date is invalid.




