Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Date field value into text box

Explorer ,
Dec 09, 2025 Dec 09, 2025

I am looking for a date picked from a date field to be transposed into a text box, but in a different format and preferably in different boxes.

 

Date Field -

saledate: 11/19/2025

 

Text boxes-

text1: Nov

text2: 19

text3: 25

 

Is this possible?

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms
475
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Dec 09, 2025 Dec 09, 2025

There are several ways this could be done.  Here's a simple and straight forward method.

Use this script in the Custom Validation script for the date field:

// validate date entry first
if(/\d{1,2}\/\d{1,2}\/\d{4}/.test(event.value))
{
    var dtValue = util.scand("mm/dd/yyyy",event.value);
    this.getField("text1").value = util.printd("mmm",dtValue);
    this.getField("text2").value = util.printd("dd",dtValue);
    this.getField("text3").value = util.printd("yy",dtValue);
}

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 12, 2025 Dec 12, 2025

There was something I was clearly doing wrong yesterday, because it worked just fine this morning! I still attached the PDF for anyone seeing this in the future 🙂

 

Thanks, Thom!

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2025 Dec 09, 2025

There are several ways this could be done.  Here's a simple and straight forward method.

Use this script in the Custom Validation script for the date field:

// validate date entry first
if(/\d{1,2}\/\d{1,2}\/\d{4}/.test(event.value))
{
    var dtValue = util.scand("mm/dd/yyyy",event.value);
    this.getField("text1").value = util.printd("mmm",dtValue);
    this.getField("text2").value = util.printd("dd",dtValue);
    this.getField("text3").value = util.printd("yy",dtValue);
}

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2025 Dec 09, 2025

Just a small error — you’re writing all three values into text1, instead of text1, text2, text3.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2025 Dec 09, 2025

Good catch

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 11, 2025 Dec 11, 2025

I'm running into an issue with the date field. It will not pull this data if it's a date field. If I remove the date format in properties, and the date box then turns into a text box, only then does it work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2025 Dec 11, 2025

So, there really isn't a special kind of Date Field in a PDF.  It's just a text field with date formatting. If the script works only when the formatting is removed, then there is a problem with the formatting. What exactly is the date format being used?

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 11, 2025 Dec 11, 2025

mm/dd/yyyy

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2025 Dec 11, 2025

That should work just fine.  Can you post the form?

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 12, 2025 Dec 12, 2025

There was something I was clearly doing wrong yesterday, because it worked just fine this morning! I still attached the PDF for anyone seeing this in the future 🙂

 

Thanks, Thom!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2025 Dec 12, 2025
LATEST

Excellent! Sometimes things don't get saved correctly. Or Acrobat needs to get kicked. It's never a bad idea to close and reopen a file, or close and reopen Acrobat, so that the memory is refreshed. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines