Skip to main content
Inspiring
August 19, 2021
Answered

Arbitrary mask more than one format

  • August 19, 2021
  • 2 replies
  • 7706 views

Hello! How might I be able to allow for two acceptable formats in a field? I'm have an elementary understanding of the arbitrary mask feature. The two formats are as follows:

 

Format 1: A999999999 (one letter & nine numbers)

Format 2: AA999999999 (two letters & nine numbers)

 

Thank you in advance!

This topic has been closed for replies.
Correct answer Nesa Nurani

Try this as custom keystroke script:

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

2 replies

Nesa Nurani
Community Expert
Community Expert
August 20, 2021

Try this as validation script:

var str = event.value;
var reg = /^[a-zA-Z]{1,2}[0-9]{9}$/;
var r = reg.test(str);
if(!r)
app.alert("Your message goes here",3);

 

dpoagAuthor
Inspiring
August 21, 2021

Thank you. It works great!

Amal.
Legend
August 19, 2021

Hi there

 

Hope you are doing well and sorry for the trouble. As described,you want to be able to allow for two acceptable formats in a field and want to user arbitrary mask format in the PDF form.

 

For more information about arbitrary mask format, please check the description under 'Format tab for form field properties' section of the help page - https://helpx.adobe.com/acrobat/using/pdf-form-field-properties.html and see if that works for you.

 

Regards

Amal

dpoagAuthor
Inspiring
August 19, 2021

I read a post that said to allow for multiple formats you need to use a custom script using the RegExp object for testing is possible format. Does this sound correct? Thank you.

Amal.
Legend
August 20, 2021

Hi there

 

You may use the custom format using the JavaScript in the PDF form. For more information about using the JavaScript please check the help page https://acrobatusers.com/tutorials/javascript_console/

 

Regards

Amal