Number validation: Cannot start or end with zero

  • 15 December 2017
  • 11 replies
  • 24 views

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

Badge +9

You can use a regular expression for validation:

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

211620_pastedImage_2.png

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

Badge +9

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

211621_pastedImage_1.png

Badge +5

When I enter that expression my form crashes:

Here is my screen

Badge +9

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

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

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

Badge +5

Ah Ha!  Thx. Will clean up.

Badge +5

That was it! Thanks

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

Badge +9

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.

Badge +5

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

Badge +9

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.

Badge +5

TY

Reply