Skip to main content
Nintex Community Menu Bar
Solved

Input validation - between 6 and 12 digits


Forum|alt.badge.img+3

I have a Nintex responsive form with a field for Account Number. This number can be a minimum or 6 digits and maximum of 12 digits. 

I need help on how I can set the Input validation regular expression to ensure users can enter a minimum of 6 digits (no spaces or characters) and a maximum of 12 digits (no spaces or characters).

Hope someone can assist!

Best answer by Garrett

Hi @campbelllansw 

 

Try this

^[0-9]{6,12}$

 

^ : Start anchor

[0-9] : Character class to match one of the 10 digits

{6,12} : Range quantifier. Minimum 6 repetition and maximum 12.

$ : End anchor

View original
Translate
Did this topic help you find an answer to your question?

14 replies

Garrett
Forum|alt.badge.img+16
  • Scout
  • 904 replies
  • Answer
  • June 28, 2023

Hi @campbelllansw 

 

Try this

^[0-9]{6,12}$

 

^ : Start anchor

[0-9] : Character class to match one of the 10 digits

{6,12} : Range quantifier. Minimum 6 repetition and maximum 12.

$ : End anchor

Translate

Forum|alt.badge.img+3

Garret, thank you so much this worked perfectly. Much appreciate. 😀

Translate

Forum|alt.badge.img+3

I have one more validation issue I am trying to resolve:

 

In the text box I need  the prefix to show in field “C-” and then the user can enter min 5 max 6 characters (digits and/or characters.

E.g. C-12345  C-123456  C-TN1234  C-Q1234

 

Hope someone can help?!

Translate

Garrett
Forum|alt.badge.img+16
  • Scout
  • 904 replies
  • June 30, 2023

Try this

^[Cc]-[0-9]{6,12}$

 

^ : Start anchor

[Cc] : Character class to match either Uppercase or Lowercase C

- : Match hyphen character 

[0-9] : Character class to match one of the 10 digits

{6,12} : Range quantifier. Minimum 6 repetition and maximum 12.

$ : End anchor

Translate

Forum|alt.badge.img+3

I really appreciate you help, but after the “C- this can be characters, e.g., TN and or digits, 12345

So C-TN1234 or C-A12345 or C-123456

Translate

Garrett
Forum|alt.badge.img+16
  • Scout
  • 904 replies
  • June 30, 2023

Let me clarify

 

First two Char is “C-”

Next is 5-6 characters which can consist of

  • TN and 3-4 digits → TN123, TN1234
  • 1 alphabet [A-Z] and 4-5 digits
  • 5-6 digits

or did you want next 5-6 any combination of alphabets and digits

Translate

Forum|alt.badge.img+3

Yes, they must always prefix with C- then the next 5 or 6 can be a combination of characters or numbers, E.g. C-TN1234 or C-123456 or C-12345 or C-A1234

 

Thanks

Translate

Garrett
Forum|alt.badge.img+16
  • Scout
  • 904 replies
  • June 30, 2023

Hey @campbelllansw 

 

First two Char is “C-”

Next is 5-6 characters which can consist of

  • TN and 3-4 digits → TN123, TN1234
  • or 1 alphabet [A-Z] and 4-5 digits
  • or 5-6 digits

^[Cc]-(TN\d{3,4}|[A-Za-z]\d{4,5}|\d{5,6})$

 

First two Char is “C-”

next 5-6 any combination of alphabets and digits

^[Cc]-(.{5,6})$

Translate

Garrett
Forum|alt.badge.img+16
  • Scout
  • 904 replies
  • June 30, 2023

Fixed. Prefix is C-

^C-.{5,6}$

Translate

Forum|alt.badge.img+3

Thank you so much Garrett….that has worked exactly as needed….very much appreciate you help and your quick response. 😀

Translate

Forum|alt.badge.img+3

Garret, can I ask for one more solution 😁

Is there any way to set the Pattern based on the choice of another fitler:

For example:

I have a choice field “Area Code”

If the user selects 02,03,04,05,06,06,08,09 then the length on the Telephone field is set to max 8 digits.

If the user select INTL then the Telephone field max digits is 15.

I looked at the rules but could not see any actions there that would set the rule?

 

Thanks

Translate

Forum|alt.badge.img+1
  • Novice
  • 4 replies
  • May 7, 2024

Is there a way to tweak this formula to enforce exactly five characters in a single-line-of-text field?  I already have a rule that enforces the value be numeric, as well as column setting to enforce a max of 5 characters, but I need to force the user to enter a minimum of five characters as well (it’s for a zip code).  Also, where is this formula to be used?  Control settings?  Rule on the control?  Javascript?

Translate

  • 70 replies
  • May 7, 2024
dale_black wrote:

Is there a way to tweak this formula to enforce exactly five characters in a single-line-of-text field?  I already have a rule that enforces the value be numeric, as well as column setting to enforce a max of 5 characters, but I need to force the user to enter a minimum of five characters as well (it’s for a zip code).  Also, where is this formula to be used?  Control settings?  Rule on the control?  Javascript?

You use it in the field controls under the validation tab, you can select Yes under “Use Regular Expression”. Then you can enter a regular expression that has to match whatever the users have to fill out. If you want to enforce exactly five characters, either letters or numbers, you can use ^\w{5}$. \w is the code for letters or numbers, and curlybraces detail how many. If you want five digits (numbers 0 to 9) you can use \d instead of \w. ^ details the start of the string, so it shouldn’t have anything else preceding it, and $ denotes the end of the string, meaning it shouldn’t have anything after it. Some examples:

  • ^\w{5}$ matches exactly five characters, either letters or numbers like aBcde or q5ef3 or 12345 but not 124tew
  • ^\d{5}$ matches a five digit number, for instance 00000 or 12456 but not a532g
  • ^[a-z]{5}$ matches five lowercase letters, for instance abcde or aaaaa but not ALOv1 or FAahg
  • ^[A-Z]{5}$ matches five uppercase letters, for instance ABCDE or AAAAA but not aaaaa or AA341 or ABCDEF
Translate

Forum|alt.badge.img+1
  • Novice
  • 4 replies
  • May 7, 2024
BobR wrote:
dale_black wrote:

 

You use it in the field controls under the validation tab, you can select Yes under “Use Regular Expression”. Then you can enter a regular expression that has to match whatever the users have to fill out. If you want to enforce exactly five characters, either letters or numbers, you can use ^\w{5}$. \w is the code for letters or numbers, and curlybraces detail how many. If you want five digits (numbers 0 to 9) you can use \d instead of \w. ^ details the start of the string, so it shouldn’t have anything else preceding it, and $ denotes the end of the string, meaning it shouldn’t have anything after it. Some examples:

  • ^\w{5}$ matches exactly five characters, either letters or numbers like aBcde or q5ef3 or 12345 but not 124tew
  • ^\d{5}$ matches a five digit number, for instance 00000 or 12456 but not a532g
  • ^[a-z]{5}$ matches five lowercase letters, for instance abcde or aaaaa but not ALOv1 or FAahg
  • ^[A-Z]{5}$ matches five uppercase letters, for instance ABCDE or AAAAA but not aaaaa or AA341 or ABCDEF

 

Awesome!  I didn’t think it was that simple.  Much appreciated!

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings