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

Date validation

TimTam_123
Registered: Oct 31 2011
Posts: 6
Answered

I have created a form in acrobat, where I have date field specified from the properties dialog box, so that it is limited to 10 characters and that the format is a custom format of dd/mm/yyyy. So, once the user types it in the wrong format, they get an "alert message". This is all done automatically from the properties dialog box, as you all know.
 
Now, If I want to change the "alert" text to french, how do I go about doing it? I'm assuming I have to put in custom validation javascript? Can anyone help me with this script? I've got no javascript experience at all and would appreciate your help!
 

My Product Information:
Acrobat Pro 9.4.3, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
I don't think there's a way to specify the locale of the error messages that Acrobat displays. Maybe if you use the localized version of Acrobat you'd also get localized error messages, but I can't guarantee that.
However, there is a way around it, by creating your own validation method, based on those embedded in Acrobat.
For example, I've created the following function that can be used to validate a Date field (you can place it at the doc-level).

  1. function AFDate_KeystrokeEx_FR(cFormat) {
  2. if (event.willCommit && !AFParseDateEx(AFMergeChange(event), cFormat)) {
  3. if (event.willCommit && !event.silenceErrors) {
  4. var cAlert = "ERROR MESSAGE PART 1"; // This part will appear before the name of the field.
  5. var cAlert2 = "ERROR MESSAGE PART 2"; // This part will appear before the correct field format.
  6. if (event.target != null) {
  7. cAlert += "[ " + event.target.name + " ]";
  8. }
  9. cAlert += cAlert2 + cFormat;
  10. app.alert(cAlert);
  11. } else {
  12. app.beep(0);
  13. }
  14. event.rc = false;
  15. }
  16. }
To use it select the field's Format to be Custom, and enter this this as the Custom Keystroke Script:
  1. AFDate_KeystrokeEx_FR("mm/dd/yyyy"); // change the date format if you wish
You'll notice that after you do so the format automatically changes to Date, but that's OK because underwater it's still using the function we defined. So now you can customize your error messages to whatever text you want and you don't have to re-write the lengthy validation functions used by Acrobat.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

TimTam_123
Registered: Oct 31 2011
Posts: 6
I'll give this a whirl and see what happens...thank you! Where do I embed the "function" script you've written above? Sorry, I don't know what you mean by "place it at the doc-level"?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Advanced - Document Processing - Document JavaScripts.
Create a new script and paste the function code there.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

TimTam_123
Registered: Oct 31 2011
Posts: 6
Thank you that works!

If you don't mind...I have one more question...I'm having the same problem with my number field. In acrobat, in properties I had set the "field value is in range: from 0-50)", and then if you fill in something above that amount, there's an automatic error message that comes up that says "Invalid value: must be greater than or equal to 0 and less than or equal to 50". This is built into the properties, but I need that message to come up in french.

What would I have to do if I wanted to make this message french? Is there a workaround for this as well?
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Hi TimTam_123,

did you try your form with several Reader's versions and with several computers ?

I'm a french using a french Acrobat and Reader, and all these alerts are normally displayed in french languageā€¦

;-)
TimTam_123
Registered: Oct 31 2011
Posts: 6
oh no..I didn't. I use the english version. So does that mean I wouldn't have to change the text then? Will it translate automatically to french if let's say someone in Montreal uses it?
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Of course, if you are using an english version of Reader/Acrobat, alerts are displayed in english language.
If you are using a french version of Reader/Acrobat, alerts are displayed in french language.
If you are using a german version of Reader/Acrobat, alerts are displayed in german languageā€¦
Etc.

Acrobat is available in 28 languages total, and add another couple of languages for Reader. The language set includes most major western European languages, several languages from Asia and the middle east, and Reader also is available in Catalan and Basque.

;-)