Skip to main content
Nintex Community Menu Bar

Number validation: Cannot start or end with zero

  • December 15, 2017
  • 11 replies
  • 33 views

Forum|alt.badge.img+5

Is there a way to validate end user entry so that the 1st and last number upon data entry cannot be a zero? 

Here is what the department would like: 

XYZ #: 6 numbers max (done), Numbers only (Done), Cannot start or end with 0 (not done) 

The field was created in SharePoint 2013 and set at one line text, 6 char max.  In Nintex I set the validation for numbers only. 

11 replies

Forum|alt.badge.img+9
  • December 18, 2017

You can use a regular expression for validation:

^([1-9]d{0,4}[1-9]|d)$

211620_pastedImage_2.png


Forum|alt.badge.img+5

Thank you for the reply. I am looking at this and I am sure it makes sense but I am confused as to how to apply it to my situation.


Forum|alt.badge.img+9
  • December 18, 2017

Use the following settings for single line text control in Nintex Forms:

211621_pastedImage_1.png


Forum|alt.badge.img+5

When I enter that expression my form crashes:

Here is my screen


Forum|alt.badge.img+9
  • Nintex Partner
  • December 18, 2017

You have an extra ) added after 1-9]) <----

 ^([1-9])d{0,4}[1-9]|d)$

 ^([1-9]d{0,4}[1-9]|d)$


Forum|alt.badge.img+5

Ah Ha!  Thx. Will clean up.


Forum|alt.badge.img+5

That was it! Thanks

‌ - Big thanks to you for getting this going and solved.


Forum|alt.badge.img+9
  • December 18, 2017

Sorry, please change ^([1-9]d{0,4}[1-9]|d)$ to ^([1-9]d{0,4}[1-9]|[1-9])$

This ensures that numbers with only one digit may not have the value 0.


Forum|alt.badge.img+5

What is a good resource to reference this syntax so I can learn and build upon it?


Forum|alt.badge.img+9
  • December 18, 2017

there are so many tutorial sites for regular expressions. See Regex Tutorial—From Regex 101 to Advanced Regex , play with online tester Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript and check Microsoft docu for .NET regular expressions.


Forum|alt.badge.img+5

TY