Solved

Input validation - between 6 and 12 digits


Badge +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!

icon

Best answer by Garrett 28 June 2023, 05:23

View original

11 replies

Userlevel 6
Badge +16

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

Badge +3

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

Badge +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?!

Userlevel 6
Badge +16

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

Badge +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

Userlevel 6
Badge +16

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

Badge +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

Userlevel 6
Badge +16

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})$

Userlevel 6
Badge +16

Fixed. Prefix is C-

^C-.{5,6}$

Badge +3

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

Badge +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

Reply