Skip to main content
Participant
April 11, 2017
Answered

Acrobat - Majuscule sur champ date de type MMM YYYY

  • April 11, 2017
  • 3 replies
  • 3567 views

Bonjour,

Nous utilisons Acrobat Pro pour gérer nos formulaires et utilisons les scripts de validation pour obtenir le format souhaité de nos champs.

Nous arrivons à tous les faire fonctionner sauf un : le format MAR 2017. Normalement, il suffit de mettre le format "mmm YYYY" mais le soucis est que les 3 lettres du mois sont en minuscule au lieu d'être en majuscule.

J'ai résolu ce problème sur d'autres champs en ajoutant le script de validation suivant : event.value = event.value.toUpperCase();

Habituellement, cela fonctionne bien et remet le texte en majuscule sauf que là, non : il reste en minuscule. J'ai l'impression que le format reprend la main sur le script de validation.

Auriez-vous une idée pour obtenir la date sous le bon format svp ?

Merci d'avance.

Cordialement.

This topic has been closed for replies.
Correct answer try67

You're right, the Format option takes precedence over the validation script so any changes in the latter are not seen after the former is executed.

What you will need to do is use a custom Format/Validation script to perform both tasks.

I've written this code if you want to use it as a Format script (ie, without changing the actual value of the field, just the way it appears):

var cFormat = "mmm yyyy";

var f = this.getField("Date1");

f.setAction("Format", "AFDate_FormatEx(\""+cFormat+"\"); event.value = event.value.toUpperCase();");

f.setAction("Keystroke", "AFDate_KeystrokeEx(\""+cFormat+"\");");

To use it adjust the field name in the second line and then run this code from the JS Console.

3 replies

JR Boulay
Community Expert
Community Expert
May 30, 2017

Je me doute bien que ça résulte d'une contrainte technique, c'est pour ça que j'ironise.

Plus sérieusement, pour faire suite à ce qui est dit ci-dessus je crois que ceci devrait fortement t'intéresser.

L’ordre d’exécution des événements dans les champs de formulaire PDF enfin expliqué clairement (et en français) :

https://www.abracadabrapdf.net/ressources-et-tutos/js-et-formulaires-ressources/lordre-dexecution-des-evenements-dans-le…

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
May 29, 2017

In french and with some months, there is an accent on one of the 3 letters  (fév, déc) and this is a problem for us.

Arglll.

Un hérétique !

==> https://www.abracadabrapdf.net/divers-2/lettres-capitales-accentuees/

Acrobate du PDF, InDesigner et Photoshopographe
Participant
May 30, 2017

Merci pour ta réponse cependant, le cas précis dont nous parlons n'est pas lié à la bonne pratique de notre langue française mais à des indications qui sont imprimées sur nos produits. Les imprimantes de marquage ne savent pas parler le bon français et ne gèrent donc pas ces accents. Nos documents émanant d'Acrobat devant être strictement identiques à ce qu'il y a sur nos emballages, nous n'avons pas le choix.

Donc en définitive, pas le choix : nous avons besoin d'enlever ces accents ...

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 11, 2017

You're right, the Format option takes precedence over the validation script so any changes in the latter are not seen after the former is executed.

What you will need to do is use a custom Format/Validation script to perform both tasks.

I've written this code if you want to use it as a Format script (ie, without changing the actual value of the field, just the way it appears):

var cFormat = "mmm yyyy";

var f = this.getField("Date1");

f.setAction("Format", "AFDate_FormatEx(\""+cFormat+"\"); event.value = event.value.toUpperCase();");

f.setAction("Keystroke", "AFDate_KeystrokeEx(\""+cFormat+"\");");

To use it adjust the field name in the second line and then run this code from the JS Console.

Participant
April 11, 2017

Thanks a lot, it works perfectly !!

The only strange think is that the script diseappers when we go back to the format screen:

Thanks again !  ; )

Participant
May 29, 2017

Yes, that's a bug of Acrobat when you use one if the built-in methods for

Format/Keystroke in your code... It should still work, though.


Thanks again for the answer.

The users have a new question about the same purpose.

In french and with some months, there is an accent on one of the 3 letters  (fév, déc) and this is a problem for us.

Is ther a way to keep the first format and use another fonction to delete the accents ?

Thanks !!

Regards