Level 1

0% to

Level 2

Tip /

to gain points, level up, and earn exciting badges like the new
Mission!

View all

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

## RegExp multiple character counts

Level 3

I am trying to get this to allow me to choose either a 5 digit number, or a 10 digit number. It works fine as is for the 5 digit number, but I can't figure out how to get the second expression for the 10 digit number. I've tried the | for an "or" expression. I know it is just the way I am setting it up, just can't seem to find anything online that shows me exactly the same thing as an example, and I've tried every combination I can think of.

Any help would be greatly appreciated.

Thanks

var r = new RegExp();

r.compile("^([0-9]{5})\$","i");

var result = r.test(this.rawValue);

if (result == true) {

this.fillColor = "255,255,255";

this.border.edge.color.value = "255,255,255"

true;

}

else {

app.alert("You must enter the Designer's 5 digit PAX or 10 digit phone number.", 0);

this.fillColor = "255,255,0";

xfa.host.setFocus(this);

this.border.edge.color.value = "255,255,0"

}

1 Accepted Solution

Level 10

Hi,

should work this way:

if (!this.rawValue.match(/^([0-9]{10}|[0-9]{5})\b/g)) {

xfa.host.messageBox("You must enter the Designer's 5 digit PAX or 10 digit phone number.");

}

0 Replies

Level 10

Hi,

should work this way:

if (!this.rawValue.match(/^([0-9]{10}|[0-9]{5})\b/g)) {

xfa.host.messageBox("You must enter the Designer's 5 digit PAX or 10 digit phone number.");

}

Level 3

That did the trick. Thank you very much!