Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

RegExp multiple character counts

Avatar

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

Avatar

Correct answer by
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.");

}

View solution in original post

2 Replies

Avatar

Correct answer by
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.");

}

Avatar

Level 3

That did the trick. Thank you very much!