Copy link to clipboard
Copied
How can I format a PDF form date field as example " 12TH DAY OF JANUARY, 2018 " (Acrobat 2017 PRO)
Copy link to clipboard
Copied
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();
"
Copy link to clipboard
Copied
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").
Copy link to clipboard
Copied
You should use a custom format, like this one:
dd\t\h \d\a\y \o\f mmmm, yyyy
Text field properties : Format : Date :
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
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"...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
"
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
yes.. no error from "custom validation script " .. except when in testing when I did intentionally enter an invalid date..
Copy link to clipboard
Copied
Did you open the JavaScript console by using the <Ctrl> + "J" key combination?
Copy link to clipboard
Copied
The issue exists in IE and Acrobat pro
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
yes ..
"
ReferenceError: legalDate is not defined
3:Field:Format
"
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I can send my failing one cell form..
Copy link to clipboard
Copied
It is a TEST form that fails
Copy link to clipboard
Copied
I currently have NO form that works.. all fail
Copy link to clipboard
Copied
FIXED .. you were correct both the "getOrdinalNum" and "legalDate" when added resolved the issue.. My nubee THANKS! for you help..

