How to Validate HH:mm Time Format in Acrobat PDF Forms
Question details
The user needs a method to ensure respondents enter a valid 24-hour time format (HH:mm, such as 23:34) into a specific field within an Acrobat PDF form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or modifying an interactive PDF form where accurate time data collection is required from respondents.
- Observed behavior
- The form field must reject invalid time entries and prompt the user to input the correct 24-hour HH:mm format.
Ensure you have the necessary editing permissions for the PDF form and access to the form field properties where the formatting or validation script will be applied.
Use Built-in Acrobat Time Format Settings
The simplest and most reliable way to enforce a time format without coding is by using Acrobat's built-in format options.
Before writing custom JavaScript, check if the native formatting features meet your needs. Built-in formats are generally more stable across different PDF viewers.
Enter form editing mode in Acrobat. Right-click the text field you want to format and select 'Properties'.
In the Text Field Properties dialog box, click on the 'Format' tab located at the top.
Click the 'Select format category' drop-down menu and choose 'Time'.
From the 'Time Options' list, select the 24-hour format that displays as 'HH:mm' (e.g., 13:30). Click 'Close' to save your changes.

Apply Custom JavaScript Validation for HH:mm Format
If you need strict control over the input or wish to display a custom error message, you can apply a JavaScript Regular Expression (Regex) to the field.
Create and Edit PDF Forms Easily with WPS Office
WPS Office features a robust PDF editor that simplifies creating, editing, and filling out interactive PDF forms. You can easily manage text fields, checkboxes, and drop-down menus without needing complex JavaScript knowledge.
- 1. Open PDF in WPS Office: Launch WPS Office and open the PDF document you wish to turn into an interactive form.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to view all available interactive form controls.
- 3. Insert Form Fields: Select 'Text Field' and click on the document area where you want respondents to enter data.
- 4. Customize Properties: Double-click the newly created field to adjust its properties, naming, and basic formatting.
- 5. Save and Distribute: Click 'Save' to ensure your interactive PDF form is ready for users to fill out.

Frequently Asked Questions
Why isn't my JavaScript validation working in the PDF form?
Ensure that JavaScript is enabled in your PDF viewer's preferences. Additionally, check the JavaScript console for syntax errors in your regex code, as a single misplaced character can break the script.
Can I validate a 12-hour time format (hh:mm AM/PM) instead?
Yes. You can either select the 12-hour format option under the built-in 'Format' tab settings, or adjust your regex pattern to validate numbers 01-12 followed by AM or PM.
Do custom PDF validation scripts work on mobile devices?
Support for custom JavaScript in PDF forms varies widely depending on the mobile PDF reader app. Built-in format options are generally more widely supported across mobile platforms than complex scripts.
How do I clear the field if an invalid time is entered?
When using the custom script method, setting `event.rc = false;` rejects the invalid input and typically forces the user to correct the value before navigating away from the field.




