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

How do I only allow specific text for a user input field?

Jump to solution

I have a single line text control in an item form and I'm having trouble with the exact validation settings to produce the desired result.  I'm new to regex but I've managed to at least set validations to allow all alphanumeric characters and just the dash ( - ) special character.  However, what I would really like is to only allow specific two-letter combinations (i.e. NW, SU), two-digit numbers (1-99) and the dash ( - ) special character.  I've attempted many permutations in regex (scouring the web and these forums for clues) but have had no luck so far.  Any help would be much appreciated and thanks!

0 Kudos
Reply
6 Replies
Automation Master
Automation Master

Re: How do I only allow specific text for a user input field?

Jump to solution

Is there a restricted set of allowed two-letters combinations? Or any two-letter combination is allowed? Is there any rule/pattern what combinations are allowed?

Is there any rule/pattern what should/have to be sequence of letters and digits groups and a dash?

Could you some samples of allowed  and not allowed  inputs?

0 Kudos
Reply
coreyblanton
Nintex Newbie

Re: How do I only allow specific text for a user input field?

Jump to solution

There is a set of restricted combinations--AM, SU, NW, MI, and MA (upper and lowercase are permitted)--I'm just unsure of the necessary syntax to declare them in an expression.

0 Kudos
Reply
Automation Master
Automation Master

Re: How do I only allow specific text for a user input field?

Jump to solution

from so far quite vague set of requirements I can recommend eg. following regex expression

^((AM|SU|NW|MI|MA)|(\d{2})|(-(?!-)))+$

see some of inputs that it matches (colored) and that not

to satisfy your requirement of case insensitivity, above regex expression need /i flag to be applied.

assume, you use custom regular expression validation in control's settings. this feature unfortunately doesn't support regex flags.

so you you need to make above regex expression bit more complex

^(([aA][mM]|[sS][uU]|[nN][wW]|[mM][iI]|[mM][aA])|(\d{2})|(-(?!-)))+$

I'm not sure whether this suits you or not.

but until you specify your exact requirements in more details  that's the most you can expect.

0 Kudos
Reply
coreyblanton
Nintex Newbie

Re: How do I only allow specific text for a user input field?

Jump to solution

Apologies for not being more specific.  The alphanumeric combinations are a naming convention for specific actions in the application process for coal mining permits.  The combinations are the letter pairs AM, SU, MI and MA followed by a dash then a two-digit number (i.e. MA-05).  NW uses no number since it represents the first permitting action (new).  There are also occasions which would necessitate using a combination such as NW-AM-05.  Case sensitivity is unnecessary (and makes input easier for the users) since I can just use the ToUpper function to display the values on forms in all caps if need be.  The expression you've written works perfectly based on the requirements I described in my original question.  Requiring only two-digit number combinations after the dash for the letter pairs AM, SU, MI and MA would be the only other validation I would like in the expression--but I understand if you've already devoted enough time to this endeavor.  Thanks again for your contribution!

0 Kudos
Reply
Automation Master
Automation Master

Re: How do I only allow specific text for a user input field?

Jump to solution

I still have some minor doubts, but let's try following

^((NW)|(?(?=NW-)(NW-(AM|SU|MI|MA)-\d{2})|(AM|SU|MI|MA)-\d{2}))$

0 Kudos
Reply
coreyblanton
Nintex Newbie

Re: How do I only allow specific text for a user input field?

Jump to solution

Sorry I haven't replied sooner (I wear a lot of hats in our agency).  I put together an amalgamation of both expressions and it works perfectly!!  Thanks so much again for your help!

Reply