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

Format a Date Field to Another Formatting

Explorer ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

I worked on a Tool that can build PDF Forms. In this tool, I defined a DateTime field. I genereated an PDF Form which has a candenler that can allow user to choose the date. But the formatting is not what I wanted(see the image below). We wanted it shows MM/DD/YYYY

Blair285268942h5r_0-1690419129446.png

I posted formatting issue before which is about currency formating, the code is like this:

var Minisalary = this.getField("MiniSalary");
Minisalary.setAction("Format", "event.value = formatCurrency(event.value);");

 

So, I am wondering if we can do simialir code, like below to realize it, but I tried serval ways, it failed. 

var date= this.getField("my field");
date.setAction("Format", "event.value = ???;");

 

 

 

TOPICS
How to , PDF forms

Views

620

Translate

Translate

Report

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
1 ACCEPTED SOLUTION
Explorer ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Could you please help on the coding?

 

var Date= this.getField("StartDate");
Date.setAction("Format", "event.value = formatDate ("MM/DD/YYYY");");

 

I don't know what function should be used here.

 

View solution in original post

Votes

Translate

Translate

Report

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 ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

What version of Adobe Acrobat does you use?

Votes

Translate

Translate

Report

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 ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Adobo Pro DC

Votes

Translate

Translate

Report

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 ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

There you can use the format "MM/DD/YYYY" for the date field. 

Votes

Translate

Translate

Report

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 ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Could you please help on the coding?

 

var Date= this.getField("StartDate");
Date.setAction("Format", "event.value = formatDate ("MM/DD/YYYY");");

 

I don't know what function should be used here.

 

Votes

Translate

Translate

Report

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 ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

LATEST

Sorry for confusion, please ingore the currency fomatting, the function formatDate is user-defined. Anyhow, the problem is fixed, and using below code:

 

//Date format MM/DD/YYYY, Business is a subtree, CurrentDate is a field under it. That needs a '_' between them. 
var CurrentDate = this.getField("Business_CurrentDate");
var requiredFormat = "mm/dd/yyyy";
CurrentDate.setAction("Format", "AFDate_FormatEx(\""+requiredFormat+"\")");
CurrentDate.setAction("Keystroke", "AFDate_KeystrokeEx(\""+requiredFormat+"\")");

Votes

Translate

Translate

Report

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