How to Extract Date of Birth from ID Number in PDF Forms
Question details
The user needs to automatically extract and reformat a date of birth (ddmmyyyy) from a provided ID number formatted as yymmdd####### within a PDF form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where entering a user's ID number triggers an automatic calculation to populate the Date of Birth field.
- Observed behavior
- A calculation script is required, but the two-digit year format (yymmdd) in the ID number creates a century ambiguity (e.g., 2018 vs 1918) that must be resolved.
Before writing your calculation script, decide on a century rule (e.g., treating years above 25 as 1900s, and below as 2000s) or add a specific form field to capture the correct century.
Implement a Custom JavaScript Calculation with a Century Rule
Use JavaScript in the PDF form field properties to extract the characters and apply logic to determine the correct century.
Since a two-digit year lacks century context, a calculation script must mathematically or logically determine whether the year belongs to the 1900s or 2000s. Setting a pivot year is the most common automated approach.
Open your PDF document in Adobe Acrobat, navigate to the Tools menu, and select 'Prepare Form' to enter editing mode.
Right-click the target 'Date of Birth' text field where the extracted date should appear, and select 'Properties'.
Click the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button.
Enter JavaScript to extract the substrings. For example: var id = this.getField('IDNumber').value; var yy = id.substring(0,2); var mm = id.substring(2,4); var dd = id.substring(4,6);.
Add an if-statement to append the century (e.g., if(Number(yy) > 25) { year = '19' + yy; } else { year = '20' + yy; }), then output the final string in ddmmyyyy format by setting event.value = dd + mm + year;.

Add a Century Selection Field to Resolve Ambiguity
If a programmed century rule is too rigid or risky for your use case, allow the user to explicitly select their birth century to append to the extracted string.
Edit and Manage PDF Forms Easily with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to effortlessly view, edit, and fill interactive forms. It simplifies document management without the need for complex software.
- 1. Install WPS Office: Download and install the free version of WPS Office from the official website.
- 2. Open Your PDF: Launch WPS Office, switch to the PDF tab, and open your PDF form directly within the WPS PDF Editor.
- 3. Fill or Edit the Form: Use the integrated Form tools to fill interactive text fields, add signatures, or modify PDF content effortlessly.

Frequently Asked Questions
Why does my PDF script extract the wrong century from an ID number?
A two-digit year (like '18') lacks century context. You must implement a logic rule in your JavaScript (such as treating numbers under 30 as 2000s) to parse it correctly, otherwise the script does not know if it means 1918 or 2018.
Can I extract data without using JavaScript in a PDF form?
For simple text duplication, you can name two fields identically to mirror their content. However, transforming a complex string like 'yymmdd' into 'ddmmyyyy' requires custom JavaScript calculations.
How do I access the calculation script window in Adobe Acrobat?
Enter Prepare Form mode, right-click the target field, choose Properties, navigate to the Calculate tab, select 'Custom calculation script', and click the Edit button to open the JavaScript editor.




