How to Automatically Add X Marks Based on Date Fields in PDF Forms
Question details
The user wants a specific PDF form field to automatically display an 'X' for every row where a date field has been completed.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form with multiple rows of date fields, requiring an automated tracking field that counts or visually marks each valid date entry with an 'X'.
- Observed behavior
- Currently, the tracking field does not update automatically. The goal is to implement a script that dynamically detects valid date entries and generates a corresponding string of 'X' marks.
Make sure you have a PDF editor that supports JavaScript for interactive forms, and take note of the exact field names assigned to your date columns.
Use a Custom JavaScript Calculation in the Output Field
Apply a calculation script to the result field that loops through your date fields, checks for a valid entry, and appends an 'X' to the final string.
To achieve dynamic updates based on user input, you can use a custom calculation script in your output field. The script will store the date field names in an array, loop through each one to verify if a date has been entered, and build a result string.
Open your PDF form in 'Prepare Form' mode. Check the properties of your date fields to ensure they have recognizable names (e.g., Row1Date, Row2Date) or write down their exact names.
Right-click the text field where you want the 'X' marks to be displayed and select 'Properties'.
Navigate to the 'Calculate' tab in the Properties window, select 'Custom calculation script', and click the 'Edit' button.
In the JavaScript editor, define an array with your date field names (e.g., var aFieldList = ["Date1", "Date2"];). Initialize a result string variable (var cResult = "";). Create a 'for' loop to iterate through the array. Inside the loop, check if the field value matches a date pattern, and if so, append 'X' to your result string (cResult += "X";).
At the end of the script, assign the final string to the output field using 'event.value = cResult;'. Click 'OK', close the properties window, and test your form.

Manage Interactive PDF Forms Seamlessly with WPS Office
If you frequently work with interactive PDF documents, WPS Office provides a comprehensive built-in PDF editor that makes filling, viewing, and managing form fields effortless.
- 1. Install WPS Office: Download and install the free WPS Office suite on your device.
- 2. Open Your PDF Document: Launch WPS PDF and open your interactive PDF form.
- 3. Fill Out Form Fields: Click on the highlighted text fields, checkboxes, or date fields to input your data easily.
- 4. Save and Export: Once your form is completely filled, click 'Save' or export the document to share it securely.

Frequently Asked Questions
Can I use this script if my date fields are named randomly?
Yes, but you will need to manually list every single exact field name in your script's array. It is highly recommended to use a consistent naming pattern so the script can loop through them easily.
Why is the calculation script not updating immediately when I type a date?
Form calculations typically trigger only after you click outside the modified field or hit Enter to commit the data. Also, ensure your PDF viewer's preferences are set to automatically calculate field values.
How do I ensure the script only counts valid dates and not random text?
You can incorporate JavaScript Regular Expressions (Regex) within your loop to test the field's value. The script will only append the 'X' if the entered text matches your specified date format (e.g., MM/DD/YYYY).
Do JavaScript form calculations work on mobile PDF readers?
Advanced JavaScript calculations are mostly supported on robust desktop PDF editors. Many mobile PDF viewing apps do not support custom scripts, so the dynamic 'X' marks might not update correctly on smartphones.




