Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


RegEx for more than one arbitrary mask format

Explorer ,
Aug 19, 2021 Aug 19, 2021

Copy link to clipboard

Copied

I've heard that RedEx script is needed to accomodate more than one arbitrary mask format in a field. How might I be able to allow for the two formats in one field as follows?:

 

Format 1: OOOOOOOOOOO (11 characters)

Format 2: OOOOOOOOOO (10 characters)

 

Thank you in advance!

TOPICS
JavaScript, PDF forms

Views

36

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Aug 20, 2021 Aug 20, 2021
Thank you. I was given the below validation script and it worked! 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);

Likes

Translate

Translate
Adobe Community Professional ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

What does "O" stand for? Any character whatsoever?

And do you want it to only accept a value that's 10 or 11 characters long?

If so, you need a validation script, not a format script.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

LATEST

Thank you. I was given the below validation script and it worked!

 

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines