How to Validate a Complete dd/mm/yyyy Date Format in a PDF Form
Question details
The user needs to force respondents to enter a complete date in the exact dd/mm/yyyy format in a PDF form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or configuring an interactive PDF form that requires strict, fully formatted date inputs from users.
- Observed behavior
- The default PDF date field accepts incomplete shorthand entries such as 'dd/mm' instead of requiring the full four-digit year format.
Ensure you have access to the form editing mode and field properties in your PDF editor, as you will need to apply a custom JavaScript validation script.
Use Custom JavaScript and Regular Expressions for Date Validation
Apply a custom JavaScript snippet to the date field's validation properties to enforce the strict dd/mm/yyyy format and prevent partial entries.
By default, standard PDF field formatting might accept partial dates and autocomplete the current year. Using a custom validation script ensures that the format exactly matches 10 characters using Regular Expressions, and that the date itself is logically valid using the util.scand method.
Open your PDF document in your PDF editor and enter the 'Prepare Form' or form editing mode.
Right-click the target date input field and select 'Properties' from the context menu.
In the Properties dialog box, go to the 'Validate' tab and select the 'Run custom validation script' option.
Click the 'Edit' button and paste the following code: if (event.value) { var d = util.scand('dd/mm/yyyy', event.value); if (!/^\d{2}\/\d{2}\/\d{4}$/.test(event.value) || d == null) { app.alert('Enter a valid date in the format dd/mm/yyyy'); event.rc = false; } }
Click 'OK' to save the script, close the properties window, and exit form editing mode to test the field by entering both partial and complete dates.

Create and Fill PDF Forms with WPS PDF
WPS Office provides a comprehensive PDF editor that allows you to easily view, fill, and manage PDF forms. It offers a user-friendly interface for document editing, conversion, and seamless form handling.
- 1. Launch WPS Office: Open WPS Office and select the PDF tab to access the built-in PDF editor.
- 2. Open Your PDF Form: Import or open your PDF form document directly within the application.
- 3. Interact with Form Fields: Click directly on the interactive fields to fill in dates, text, and checkboxes seamlessly.
- 4. Save and Export: Save your completed PDF form securely or export it to share with others.

Frequently Asked Questions
Why does my PDF date field accept partial dates by default?
Standard date formatting in many PDF editors allows shorthand entries (like dd/mm) for user convenience, automatically assuming the current year. To prevent this, strict validation requires custom JavaScript.
Can I change the date validation to an mm/dd/yyyy format instead?
Yes. To change the format, adjust the custom script to match the new pattern. Change the util.scand parameter to 'mm/dd/yyyy' and update your regular expression accordingly if you use different separators.
What does the util.scand method do in Acrobat JavaScript?
The util.scand method converts a date string into a JavaScript Date object based on a specified format string. If the user's input doesn't match a logically valid date, it returns null, making it ideal for validation checks.
Will this custom JavaScript validation work on mobile PDF readers?
JavaScript support varies significantly across mobile PDF viewers. While it works reliably on desktop applications like Adobe Acrobat and WPS Office, many basic mobile readers or built-in browser viewers may ignore custom validation scripts.




