Copy link to clipboard
Copied
I'm not a developer, although I can hack through code. I can't seem to find an answer for what seems to be a basic question.
I'm trying to set a a text field to accept only specific capitalized letters.
Any help would be wonderful.
Thanks in advance
(Acrobat Pro DC)
Copy link to clipboard
Copied
Just to clarify: This code will not prevent the user from entering the not-allowed characters, but it will reject the new value once you exit the field. If you want it to only allow them to enter those characters then you can use this as the Keystroke script:
event.rc = /^[ACD]?$/.test(AFMergeChange(event));
(It's normal if the script disappears once you enter it. It should still work)
Copy link to clipboard
Copied
Would it would to create a drop down list with those specific capitalized letters?
Copy link to clipboard
Copied
I wanted to avoid a dropdown b/c the field is wide enough for one letter and the dropdown arrow would be problematic.
Copy link to clipboard
Copied
I think you would need to go for regular expressions in the field validation
Copy link to clipboard
Copied
I wanted to avoid a dropdown b/c the field is wide enough for one letter and the dropdown arrow would be problematic.
Copy link to clipboard
Copied
You can do it with the following custom validation script:
if (event.value) event.rc = /^[AVXZBD]$/.test(event.value)
Edit: To clarify, the allowed letters are those between the square brackets.
Copy link to clipboard
Copied
Thanks. I'll try it out.
Copy link to clipboard
Copied
Unfortunately, that didn't work when placed in the Validate > Run custom validation script area nor the Format > Custom Keystroke Script of the Text Field Properties
Thanks anyway.
Copy link to clipboard
Copied
Worked fine for me. What happens when you try it? Also, did you edit the code in any way? If so, how?
Copy link to clipboard
Copied
I didn't alter the code except to change the input characters in the brackets to [ACD].
The code didn't change anything; text field functioned as a text field.
if (event.value) event.rc = /^[ACD]$/.test(event.value)
Copy link to clipboard
Copied
Just to clarify: This code will not prevent the user from entering the not-allowed characters, but it will reject the new value once you exit the field. If you want it to only allow them to enter those characters then you can use this as the Keystroke script:
event.rc = /^[ACD]?$/.test(AFMergeChange(event));
(It's normal if the script disappears once you enter it. It should still work)
Copy link to clipboard
Copied
I appreciate your assistance, but neither pieces of code work for me.
Thanks anyway.
Copy link to clipboard
Copied
I take that back. The code: event.rc = /^[ACD]?$/.test(AFMergeChange(event));
is functioning as only allowing an A C or D
Thank you very much
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more