Skip to main content
Participant
January 15, 2024
Answered

In Acrobat Pro, is it possible for letters input in a text field to be automatically made uppercase?

  • January 15, 2024
  • 2 replies
  • 802 views

Further, is possible to restrict the text field to letters and hyphens?

This topic has been closed for replies.
Correct answer try67

You can do it using this code as the field's custom Keystroke script:

 

event.rc = /^[-a-z]*$/i.test(event.change);
event.value = event.value.toUpperCase();

2 replies

JR Boulay
Community Expert
Community Expert
January 15, 2024

"is possible to restrict the text field to letters and hyphens?"

Only letters can be in upper case.

😉

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 15, 2024

You can do it using this code as the field's custom Keystroke script:

 

event.rc = /^[-a-z]*$/i.test(event.change);
event.value = event.value.toUpperCase();
Participant
January 16, 2024

Thank you! I had omitted that the field should be able to accept spaces as well, but then adding a space to the character class, as follows, sorted that out.

event.rc = /^[-a-z ]*$/i.test(event.change);
event.value = event.value.toUpperCase();

 

Nesa Nurani
Community Expert
Community Expert
January 16, 2024

If you want to show uppercase as soon as you type it, replace:

event.value = event.value.toUpperCase();

with:

event.change = event.change.toUpperCase();