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

format a PDF form date as example " 12TH DAY OF JANUARY, 2018 "

Community Beginner ,
Jan 12, 2018 Jan 12, 2018

How can I format a PDF form date field as example  " 12TH DAY OF JANUARY, 2018 " (Acrobat 2017 PRO)

TOPICS
PDF forms
6.6K
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
1 ACCEPTED SOLUTION
Community Beginner ,
Jan 17, 2018 Jan 17, 2018

Thanks... I tried and it DID work GREAT  BUT now I added it to my PDF,   and it does not work ( I even tried it on a "BLANK pdf" )?   What have I missed.  ??

"// for the "Format" tab enter the following "Custom  Format Script", do not use the "Date" format option:

if(event.value != "") event.value = legalDate(util.scand("dd-mmm=yyyy", event.value)).toUpperCase();

"

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 ,
Jan 13, 2018 Jan 13, 2018

You would need to use a custom format script that will convert the user's input into this string. The trickier part is the ordinal suffix after the date ("-st", "-nd", "-rd", "-th").

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 ,
Jan 13, 2018 Jan 13, 2018

You should use a custom format, like this one:

dd\t\h \d\a\y \o\f mmmm, yyyy

Text field properties : Format : Date :

Capture_056.png


Acrobate du PDF, InDesigner et Photoshopographe
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 ,
Jan 13, 2018 Jan 13, 2018

That won't work because it's not always "th". For example, if it's the first day of the month it needs to be "1st", not "1th"...

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 ,
Jan 13, 2018 Jan 13, 2018

That won't work because it's not always "th". For example, if it's the first day of the month it needs to be "1st", not "1th"...

Yes, yes, yes.

Sorry, I did not pay attention because in French we do not have this problem, it's always the same.


Acrobate du PDF, InDesigner et Photoshopographe
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
LEGEND ,
Jan 13, 2018 Jan 13, 2018

You need to find the ordinal suffix for the day of the month and then create the formatted string;

You have not explained how the date will be entered into the form.

I would create the following document level functions:

function getOrdinalNum(n) {

// append ordinal suffix to n value;

  return n + (n > 0 ? ['th', 'st', 'nd', 'rd'][(n > 3 && n < 21) || n % 10 > 3 ? 0 : n % 10] : '');

}

function legalDate(oDate) {

// return ordinal date string form passed date object;

return getOrdinalNum(oDate.getDate()) + " day of " + util.printd("mmmm", oDate) + " " + oDate.getFullYear();

}

For auto filling a date field, create the following document level script:

// fill in field AutoLegalDate on open of PDF;

this.getField("autoLegalDate").value = legalDate(new Date()).toUpperCase();;

For entering a date value into a form field with a date format of "dd-mmm-yyyy" enter the following scripts:

// custom validation script on the "Validation tab;

if(util.scand("dd-mmm-yyyy", event.value) == null) {

app.alert("Enter valid date as dd-mmm-yyyy", 1, 0);

event.rc = false;

}

// for the "Format" tab enter the following "Custom  Format Script", do not use the "Date" format option:

if(event.value != "") event.value = legalDate(util.scand("dd-mmm=yyyy", event.value)).toUpperCase();

Link to ordinalSuffix.pdf, a working example, does not force all caps.

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

Thanks... I tried and it DID work GREAT  BUT now I added it to my PDF,   and it does not work ( I even tried it on a "BLANK pdf" )?   What have I missed.  ??

"// for the "Format" tab enter the following "Custom  Format Script", do not use the "Date" format option:

if(event.value != "") event.value = legalDate(util.scand("dd-mmm=yyyy", event.value)).toUpperCase();

"

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
LEGEND ,
Jan 17, 2018 Jan 17, 2018

Did you get any error message pop-up or in the JavaScript console?

There are 2 document level functions that need to be added to the PDF.

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

yes.. no error from "custom validation script " .. except when in testing when  I did intentionally enter an invalid date..

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
LEGEND ,
Jan 17, 2018 Jan 17, 2018

Did you open the JavaScript console by using the <Ctrl> + "J" key combination?

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

The issue exists in IE and Acrobat pro

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
LEGEND ,
Jan 17, 2018 Jan 17, 2018

If the sample form works, then there must be some difference in the scripts in the sample form and your form. Since you have access to the sample form you can see what is missing.

Without access to your form I can only guess.

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

yes ..

"

ReferenceError: legalDate is not defined

3:Field:Format

"

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
LEGEND ,
Jan 17, 2018 Jan 17, 2018

That is the name of one of the document level functions:

function legalDate(oDate) {

// return ordinal date string form passed date object;

return getOrdinalNum(oDate.getDate()) + " day of " + util.printd("mmmm", oDate) + " " + oDate.getFullYear();

}

If you are missing that function then you are certainly also missing the "getOrdinalNum" function.

You will need to add these functions as document level functions or include them in your calculation field.

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

I can send my failing one cell form..

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

It is a TEST form that fails

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 Beginner ,
Jan 17, 2018 Jan 17, 2018

I currently have NO form that works.. all fail

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 Beginner ,
Jan 17, 2018 Jan 17, 2018
LATEST

FIXED .. you were correct both the "getOrdinalNum" and "legalDate" when added resolved the issue.. My nubee THANKS! for you help..

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