Skip to main content
stepheng54012748
Known Participant
Nov 2, 2024 9:34 PM UTC
Answered

Arbitrary Mask Question

I'm hoping someone can me clean up the following Arbitrary Mask javascript I'd like to use on a form.  My goal is to change it to just 3 alphabet letters.  I can't seem to get the script right.  Here is where i'm at with this and it's not working.

 

if(event.willCommit){
var input = event.value;
var pattern = /^(|\[A-Za-z]{3}$|$/);
if (!pattern.test(input)) {
event.rc = false;
app.alert("Input must be either 3 alphabet letters, or blank.");}}

 

Thank you in advance for any ideas on how to make this work!

This topic is closed to new replies. Start a new post to keep the conversation going.
JR Boulay
JR BoulayCorrect answer
Community Expert
Nov 4, 2024 10:41 AM UTC

You don't need JavaScript to do this:

 

 

  • A - Accepts only letters (A–Z, a-z).
  • X - Accepts spaces and most printable characters, including all characters available on a standard keyboard and ANSI characters in 32–126 and 128–255.
  • O - The letter “O” accepts alphanumeric characters (A–Z, a-z, and 0–9).
  • 9 - Accepts only numeric characters (0–9).

 

 

Acrobate du PDF, InDesigner et Photoshopographe

11 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
Nov 4, 2024 10:41 AM UTC

You don't need JavaScript to do this:

 

 

  • A - Accepts only letters (A–Z, a-z).
  • X - Accepts spaces and most printable characters, including all characters available on a standard keyboard and ANSI characters in 32–126 and 128–255.
  • O - The letter “O” accepts alphanumeric characters (A–Z, a-z, and 0–9).
  • 9 - Accepts only numeric characters (0–9).

 

 

Translate
Acrobate du PDF, InDesigner et Photoshopographe
stepheng54012748
Known Participant
Nov 4, 2024 2:12 PM UTC

Yes!  This is the answer and THANK YOU!!

Translate
try67
Community Expert
Community Expert
Nov 2, 2024 11:28 PM UTC

Use this:

 

var pattern = /^[a-z]{3}$/i);

Translate
stepheng54012748
Known Participant
Nov 3, 2024 4:06 PM UTC

Here is what i input and it did not work.

 

if(event.willCommit){
var input = event.value;
var pattern = /^[a-z]{3}$/i);
if (!pattern.test(input)) {
event.rc = false;
app.alert("Input must be either 3 alphabet letters, or blank.");}}

Translate
try67
Community Expert
Community Expert
Nov 3, 2024 4:12 PM UTC

Where did you place it? Under which event?

Translate