• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

422

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

Votes

Translate

Translate
Community Expert ,
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.

Votes

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

Votes

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