PDF Editing Issues

Create an Interactive PDF in Adobe Acrobat That Sorts Birthdays by Month

Huda QurayshiHuda Qurayshi Nov 19, 2026 868 views

Question details

Create a PDF form that collects names and birthdays and displays them in monthly order.

Create an Interactive PDF in Adobe Acrobat That Sorts Birthdays by Month
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
A user wants to enter names and birthdays in a PDF form and view a grouped summary on another page.
Observed behavior
The desired summary groups entries into twelve months and sorts birthdays by day within each month.
Before you start

Open the PDF in Adobe Acrobat Pro and make sure it has a page for the summary. Check that Acrobat JavaScript and automatic form calculations are enabled in Preferences.

Solution 1Recommended

Build a Birthday Summary with Acrobat Form Fields and JavaScript

Use a calculated, multiline form field to collect entries and display them in monthly order.

This example accepts birthdays in MM/DD format and uses a leap year to validate dates, so February 29 is allowed. It omits incomplete or invalid entries and reports how many were skipped.

Acrobat's interface labels can vary by version. JavaScript support also varies between PDF viewers, so test the completed form in the viewer your recipients will use.

1
Create the entry fields

In Acrobat, open All tools > Prepare a form. Add 20 pairs of text fields named Name1 through Name20 and Birthday1 through Birthday20. Tell users to enter birthdays as MM/DD.

2
Add the summary field

On the summary page, use Prepare a form to add a text field named BirthdaySummary. In its Properties, select Multiline and set the field to read-only. Make the field large enough to display the results.

3
Add the document script

Open All tools > Use JavaScript > Document JavaScripts, create a script, and add this code: function buildBirthdaySummary() { var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var entries = []; var skipped = 0; for (var i = 1; i <= 20; i++) { var nameField = this.getField('Name' + i); var dateField = this.getField('Birthday' + i); if (!nameField || !dateField) continue; var name = nameField.valueAsString.replace(/^\s+|\s+$/g, ''); var text = dateField.valueAsString.replace(/^\s+|\s+$/g, ''); if (!name && !text) continue; var match = /^(\d{1,2})\/(\d{1,2})$/.exec(text); if (!name || !match) { skipped++; continue; } var month = Number(match[1]); var day = Number(match[2]); var date = new Date(2000, month - 1, day); if (month < 1 || month > 12 || day < 1 || date.getFullYear() !== 2000 || date.getMonth() !== month - 1 || date.getDate() !== day) { skipped++; continue; } entries.push({ name: name, month: month, day: day }); } entries.sort(function(a, b) { return a.month - b.month || a.day - b.day; }); var lines = []; for (var m = 1; m <= 12; m++) { lines.push(months[m - 1]); for (var j = 0; j < entries.length; j++) { if (entries[j].month === m) lines.push(entries[j].name + ' - ' + m + '/' + entries[j].day); } lines.push(''); } if (skipped) lines.push('Incomplete or invalid entries skipped: ' + skipped); return lines.join('\n'); }

4
Calculate the summary

In Prepare a form, open BirthdaySummary Properties > Calculate, select Custom calculation script, and enter: event.value = buildBirthdaySummary();

5
Test the form

Save the PDF, leave form-editing mode, and enter several names and MM/DD birthdays. Commit each entry by tabbing out of the field, then check that the summary updates and reports invalid entries.

Build a Birthday Summary with Acrobat Form Fields and JavaScript
Adjust the number of entries: To support a different number of people, add or remove matching Name and Birthday field pairs and change the loop limit of 20 in the document script.
Free Microsoft Office alternative

Work with PDFs and Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. Its format compatibility helps you move existing documents into WPS. Use Acrobat and a compatible PDF viewer for the custom JavaScript form described above; WPS is not presented as a replacement for that automation.

Open and review PDF documents alongside other office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface makes existing Office workflows easier to transitionFree, lightweight office suite
QA img-9

Frequently Asked Questions

What format should I use for birthdays?

Enter each birthday as MM/DD, such as 04/17. The example script also accepts single-digit months and days, such as 4/7.

Why isn't the summary updating?

Check that BirthdaySummary has the custom calculation script in Properties > Calculate, that its source fields use the exact names in the document script, and that JavaScript and automatic calculations are enabled in Acrobat Preferences.

Can the form accept February 29?

Yes. The example validates dates against the leap year 2000, so 02/29 is accepted without requiring a birth year.

Will the interactive form work in every PDF viewer?

No. PDF viewers differ in their support for form calculations and Acrobat JavaScript. Open and test the saved PDF in the viewer recipients will use.

How can I add more than 20 people?

In Prepare a form, add matching fields such as Name21 and Birthday21, then increase the loop limit in the document script to include the new pairs.