How to Make an Acrobat PDF Date Picker Read-Only After Selection
Question details
The user wants to lock a date picker field in an Acrobat PDF form, making it read-only once a user has selected a valid date.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating interactive PDF forms where the selected date needs to be finalized and protected from further edits.
- Observed behavior
- Currently, the date picker allows users to continuously change the date. The goal is to restrict editing automatically after the initial valid selection.
Ensure you have access to Adobe Acrobat Pro to edit form fields and add custom JavaScript. It is highly recommended to save a backup copy of your PDF form before applying scripts, in case you need to revert changes.
Use Custom JavaScript to Lock the Date Picker
Applying a simple JavaScript code to the date field's validation or calculation logic will make it read-only immediately after a date is chosen.
To automate the locking process, you can bind a short JavaScript snippet to the specific date field. This ensures that once the date picker writes the value into the field, it immediately locks.
Open your PDF document in Adobe Acrobat, navigate to the 'Tools' menu, and select 'Prepare Form' to enable form editing.
Right-click on the target date picker field and select 'Properties' from the context menu.
Navigate to the 'Validate' tab and select the option 'Run custom validation script'. Click the 'Edit' button.
Type the following script into the JavaScript Editor: if (event.value) { event.target.readonly = true; }. Then click 'OK' to save.
Close the form editing mode and select a date using the date picker to verify that the field successfully locks.

Finalize and Protect PDF Forms with WPS Office
Instead of relying on complex custom JavaScript, you can easily fill out your PDF forms and use WPS Office to flatten the document or restrict editing, ensuring no further changes can be made to your date pickers or text fields.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF form containing the date picker.
- 2. Fill out the Form: Select the desired date in the date picker and fill in any other necessary form fields.
- 3. Flatten or Protect the Document: Navigate to the 'Protect' tab. You can restrict editing with a password or use the 'Print' function to print to 'WPS PDF' to flatten the document, permanently locking the date field.
- 4. Save your Secure File: Save the newly protected or flattened PDF locally to share it securely without risking unauthorized edits.

Frequently Asked Questions
How can a user correct the date if the field is locked by mistake?
You can add a dedicated 'Clear' or 'Reset' button to your PDF form. Assign a JavaScript action to this button that clears the date field's value and sets the readonly property to false to unlock it.
Can I lock the entire PDF form instead of just the date picker?
Yes, you can use PDF security settings to restrict editing globally, or simply flatten the document so that all interactive fields, including date pickers, become permanent text.
Does this JavaScript read-only method work in all PDF readers?
JavaScript support varies by PDF viewer. While it works reliably in full-featured desktop software like Adobe Acrobat and WPS Office, some browser-based PDF readers or mobile viewers might ignore the script.
Why does the date picker lock before I finish selecting a complete date?
This usually happens if the script is placed in the Keystroke event rather than the Validate or Calculate event. Ensure the script runs only after a valid date has been committed to the field.




