Skip to main content
Participant
May 12, 2021
Answered

Arbitrary mask

  • May 12, 2021
  • 4 replies
  • 480 views

I want to allow up to 3 digits in a text field but if I enter 999 under the Arbitrary Mask option and only enter 2 digits in the fillable field when testing the form, I get an error message. Is there a way to type in a symbol to indicate 'up to 3 digits'?

Correct answer JR Boulay

So, instead of using the "number" format, use this script as as "Format : Custom keystroke script":

event.rc = /^\d*$/.test(event.change);

 It will keep the leading zero.

4 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
November 7, 2025

So, instead of using the "number" format, use this script as as "Format : Custom keystroke script":

event.rc = /^\d*$/.test(event.change);

 It will keep the leading zero.

Acrobate du PDF, InDesigner et Photoshopographe
Participant
November 7, 2025

Thank you JR.

Your solution will probably fit a range of cases.

What i didn't specify in my first message though , is that i need that field to be used for a UK phone number.

This means that i need the leading zeros to stay , and not sure but i might also need some flexibility like the possibility to insert 10 or 11 digits.

So , at the moment seems like the JavaScript RegEx is the way to go , for me.

JR Boulay
Community Expert
Community Expert
October 23, 2025

There is no need for JavaScript for something this simple.

In the field properties:
- Format: use the number format, without decimals
- Options: limit input to 3 characters

Acrobate du PDF, InDesigner et Photoshopographe
Participant
October 23, 2025

i have the same exact problem , and i'm afraid the only way is to resort to a JavaScript snippet of code and RegEx.

Cheers...