cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
kkittinger
Nintex Newbie

Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

Hello Community,

We have a form to do PO Numbers and those Number can be of AL or GL.  The user selects the type of PO numbers that will be entered and then starts to fill out a Repeating Section with those numbers. (This is do to depending on the type of POs they route to different people in the company that handles processing.)  We want to make sure they are entering the correct format for the numbers based on their selections.  We created the regular expressions for the AL and GL format that is needed based on the requirements that is gathered.  We have assigned a Store Client ID in JavaScript variable for the text box in the repeating section. When user moves out of the text box it calls a JavaScript function to do the validation. Even if you put in the correct format it still comes back as a bad validation.  Below is the JavaScript code we are using:

function InvalidPoNumber (source, arguments) {
 var ALRegEx = new RegExp('/(^["]\\d{2})(.{1,5}["])$|(^["]MAL)(.{1,5}["])$/gm');
 var GLRegEx = new RegExp('/^(.{1,7})$|(^MGL)(.{1,5})$/gm');
 var selection = document.getElementById(PO).value;
 if (selection == "AL") {
  if (ALRegEx.test(arguments.Value)) {
   arguments.IsValid = true;
  } else {
   arguments.IsValid = false; }
  } else if( selection == "GL") {
  arguments.IsValid = GLRegEx.test(arguments.Value);
 }
}

 

Any help or other solutions would be greatly appreciated.

Thanks,

Kevin

Reply
8 Replies
emha
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

what is a "PO" variable(?) used in getElementById? where/how do you populate it?

is PO type selector within or out of repeating section?

0 Kudos
Reply
kkittinger
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

PO is another JavaScript ID from a Choice Control to identify if the PO Numbers are going to be of Type AL or GL. This is Outside of the repeating section.

0 Kudos
Reply
emha
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

first of all update definition of regular expressions as follows

 var ALRegEx = new RegExp(/(^["]\d{2})(.{1,5}["])$|(^["]MAL)(.{1,5}["])$/gm);
var GLRegEx = new RegExp(/^(.{1,7})$|(^MGL)(.{1,5})$/gm);‍‍‍‍

the second, I would say your regular expressions still needs a bit "tuning".

I do not know what exact format of PO numbers are acceptable and what not, but your regular expressions accept some suspicious inputs.

eg. pattern  ".{m,n}" as well accepts single space characters as valid PO number.

pattern "^(.{1,7})" fully overrule its alternative pattern "(^MGL)(.{1,5})"

the same input might be accepted for both PO number types

etc.

see some examples

custom validation‌ javascript‌

Reply
kkittinger
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

Thank you for your reply, so just as more information currently our format are:

AL: (2 digits followed by A then 1-5 digits or characters) or (first three need to be MAL followed by 1-5 digits or characters)

GL: (1-7 digits or characters) or (first three need to be MGL followed by 1-5 digits or characters)

 

When I hardcode a correct or incorrect PO number in the expression work as intended, just seems when i do it from the arugments.value, i see it putting the correct entry in but just always fails the validation.

0 Kudos
Reply
emha
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

digits or characters

then I would definitely replaced all dots with \w ...

i see it putting the correct entry in but just always fails the validation

can you post an example?

0 Kudos
Reply
kkittinger
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

Here are some screen shots:

so as it shows it evaluates it shows the right value but will jump down to the else and set the IsValid to False versus Setting it to True.

0 Kudos
Reply
emha
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

that's correct

your regex pattern says valid input would be a string that starts with explicit quote sign, followed by string MAL, followed by 1 to 5 arbitrary signs and ending by explicit quote sign.

see my examples above.

quotes that debugger show just denote input is a string, they are not contained within input string/value.

Reply
kkittinger
Nintex Newbie

Re: Validating Single Test Field in Repeating Section with multiple regular expressions

Jump to solution

Thanks a lot , everything is working nicely.

Reply