These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

strange characters filling in date fields

KarenP
Registered: Aug 16 2007
Posts: 7

We have a text field on all of our forms which we prefill with the following javascript in order to capture/record the date and time in which the submit button was pressed. This is working great except in the case of our Korean end users. We are getting strange characters in the data which is causing problems with subsequent code working on the exported form data which is expecting a valid date.

forms are created in teleforms. exported to pdf. scripted in adobe 5.0. posted on the web and filled out via the web by our end users with adobe reader version 5.0 and above.

script to prefill is:
var d = new Date();
this.getField("b12c96nfgroupstudyid").value =
util.printd("dd-mmm-yyyy",d).toUpperCase() + util.printd(" HH:MM:ss",d);

I am not sure where printd retreives the date from. Is it the workstation or our server. Is there a way to force the date to be from our server versus the client workstation? Would this be the answer to this issue?

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you installed the Asian character support on your systems?

The date and time come from the variable "d" which is the date time object from the end user's system.

// get the user's system date time object into variable "d"
var d = new Date();
// fill field with the variable "d" to the formatted date string example "31-Jan-2007"
// and then add the time from variable "d" to the formatted time string example "13:30:15"
this.getField("b12c96nfgroupstudyid").value =
util.printd("dd-mmm-yyyy",d).toUpperCase() + util.printd(" HH:MM:ss",d);

The last line could be rewritten as:

// format the user's date time object like "31-JAN-2007 13:45:55"
this.getField("b12c96nfgroupstudyid").value =
util.printd("dd-mmm-yyyy HH:MM:ss",d).toUpperCase();

So one has one format string and one variable.

Or as just one line of code:

// format the user's date time object like "31-JAN-2007 13:45:55"
this.getField("b12c96nfgroupstudyid").value =
util.printd("dd-mmm-yyyy HH:MM:ss", new Date()).toUpperCase();

George Kaiser

KarenP
Registered: Aug 16 2007
Posts: 7
Thank you for your response.

What exactly do you mean by "Have you installed the Asian character support on your systems?" ? Would this apply to the web server where the form is posted and data written to fdf files etc or would it apply to the client machine with adobe reader located in Korea?

If this is coming from the client machine, do you think this is just corrupted data or is it unsupported translation of Asian characters?

Monday morning quarterbacking...we should have used mm instead of mmm, but we did not on > 300 forms.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Asian Font support would go on the user's system for western users. For non Latin languages you may have double byte or single byte character sets depending on the client's OS. It sounds like you are going to have to add additional code to translate the response to English.

George Kaiser

KarenP
Registered: Aug 16 2007
Posts: 7
Thank you again very much for your reply.

1. Let's say I do not want to change my 300 + forms,
a. is there an adobe javascript function to grab a "non client" or "server" date time when the user presses the submit button?
b.. is there a javascript function to translate this to English, independent of the language if I receive data from all over the world.
c. would using mm instead of mmm per client be universal with no translation needed.

2. obviously going to mm would take some work and testing on my side. Translating the info to English as I take it from the form to the database (1 asp page) would be the most efficient in the short term.

thanks again for your help,
karen
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
1a. No.
1b. No.
1c. Only if they use Arabic numerals.

2. Reformat the inputted date to the format you want. You can also convert the inputted local time to UTC date and time and then adjust the time to another time zone offset.

To reformat one date field to another format in another field:

event.value = "";
var sDate = this.getField("InputDate").value;
var sTime = this.getField("InputTime").value;
if (sDate !="" & sTime != "") {
var oDateTime = util.scand("dd-mmm-yyyy" + "HH:MM:ss", sDate + sTime);
event.value = util.printd("mm/dd/yyyy", oDateTime);
}To convert an inputted date to the date in another time zone:

event.value = "";
var sDate = this.getField("InputDate").value; // get inputted data
var sTime = this.getField("InputTime").value; // get inputted time
if (sDate !="" & sTime != "") { // compute only if date and time entered
// some time constants
var mSecond = 1000;
var mMinute = 60 * mSecond;
var mHour = mMinute * 60
// get the date time object for the inputted date and time
var oDateTime = util.scand("dd-mmm-yyyy" + "HH:MM:ss", sDate + sTime);
// crate the UTC date time object from the UTC date and time from the inputted date time object
var oUTCDateTime = new Date(oDateTime.getUTCFullYear(), oDateTime.getUTCMonth(), oDateTime.getUTCDate(), oDateTime.getUTCHours(), oDateTime.getUTCMinutes(), oDateTime.getUTCSeconds());
// get the time zone offset from UTC for the new time zone and convert it to milliseconds
var TZAdjust = this.getField("NewTZOffset").value * mHour;
// add the time zone offset in milliseconds to the date time object value in milliseconds
var nNewDateTime = TZAdjust + oUTCDateTime.valueOf();
// make date time object for the new time zone
var oNewDateTime = new Date(nNewDateTime);
// format the date
event.value = util.printd("mm/dd/yyyy", oNewDateTime);
}And for the time:


event.value = "";
var sDate = this.getField("InputDate").value; // get inputted data
var sTime = this.getField("InputTime").value; // get inputted time
if (sDate !="" & sTime != "") { // compute only if date and time entered
// some time constants
var mSecond = 1000;
var mMinute = 60 * mSecond;
var mHour = mMinute * 60
// get the date time object for the inputted date and time
var oDateTime = util.scand("dd-mmm-yyyy" + "HH:MM:ss", sDate + sTime);
// crate the UTC date time object from the UTC date and time from the inputted date time object
var oUTCDateTime = new Date(oDateTime.getUTCFullYear(), oDateTime.getUTCMonth(), oDateTime.getUTCDate(), oDateTime.getUTCHours(), oDateTime.getUTCMinutes(), oDateTime.getUTCSeconds());
// get the time zone offset from UTC for the new time zone and convert it to milliseconds
var TZAdjust = this.getField("NewTZOffset").value * mHour;
// add the time zone offset in milliseconds to the date time object value in milliseconds
var nNewDateTime = TZAdjust + oUTCDateTime.valueOf();
// make date time object for the new time zone
var oNewDateTime = new Date(nNewDateTime);
// format the time
event.value = util.printd("HH:MM:ss", oNewDateTime);
}

George Kaiser

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The original post is correct.

George Kaiser