Skip to main content
stepheng54012748
Known Participant
November 2, 2024
Answered

Arbitrary Mask Question

  • November 2, 2024
  • 2 replies
  • 1318 views

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 has been closed for replies.
Correct answer JR Boulay

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).

 

 

2 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
November 4, 2024

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
stepheng54012748
Known Participant
November 4, 2024

Yes!  This is the answer and THANK YOU!!

try67
Community Expert
Community Expert
November 2, 2024

Use this:

 

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

stepheng54012748
Known Participant
November 3, 2024

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.");}}

try67
Community Expert
Community Expert
November 3, 2024

Where did you place it? Under which event?