Numerical and Alpha Field Validation


Userlevel 7
Badge +11

When building a Nintex Form, you will inevitably be presented with a need for certain fields to have validation rules on them.  It could be a simple rule like the field needs to have data in it.  Or it could be that the field must be between 0 and 10.

 

In this post, we'll be talking about taking the validation to a next level, and we'll be using Regular Expressions to validation fields.  Specifically, the need to have some fields that have numbers and numbers only and others that have alpha characters and no numbers.

 

The example provided in this post will show you on-prem Nintex Forms, but the same functionality will work for Nintex Forms for Office 365.

 

Numbers Only

Firstly, since you probably already have a control on your form for this, I want to point out that we won't be using the Rules engine in Nintex Forms.  Although that is very powerful, there's no way in those rules to do this type of validation.

 

Instead, double click on the control to open the settings of that control.  There, you'll find the Validation section.  Click on it to expand it.

Numerical Validation.png

Notice that I've set the "Use a regular expression" option to Yes.  When you do that, you'll see the next fields become available.

The regular expression being used here is d+.  The d represents a digit and the + tells it that we need 1 or more of the previous token (digit).

 

Then, if the validation is not met, you have the text you can display on the form to let the user know what the issue is.

 

Alpha Only

 

For the alpha validation, it looks similar but the regular expression is a little different.

Alpha Validation.png

In this case, the expression is [a-zA-Z]+.  Where the a-zA-Z tells us that we want to went upper or lower case alpha characters and the plus means any number of those in an combination.

 

If you want to add support for spaces, you could update the expression to [a-zA-Z ]+.

 

Conclusion

 

When you run this form, what will it look like if you don't put the right data in the fields?

Preview.png

You can see how the red text tells us what the issue is.  Note: you can also put your mouse over the red fields and it'll show you the same error message but the one that is specific to that field that is invalid.

 

I've attached a form to this post.  This is for On-prem Nintex Forms only.  But the O365 version of Nintex Forms also supports this validation.


52 replies

Userlevel 6
Badge +16

The same I use!.

It 'd be great to have on future version a masked control.

Some users/forms need to validate the input on at the same time they are writting the content.

Userlevel 7
Badge +11

I agree

I'm using O365 and the "Required" flag is missing under the Validation section for what I think may be any Control that is connected to a field/list column.  Is this by design or a bug?

Userlevel 5
Badge +14

^d{6,6}-d{4,4}$

Badge +7

I need to create regular expression only to accept numeric values , but  can not have the decimal part

Has to be 27489881 and not 27489.881

Userlevel 5
Badge +14

^d+$

Badge +7

not work

Userlevel 5
Badge +14

post screenshot of your setup and example of input that do not work

Badge +7

Configuration

I Can save

Userlevel 5
Badge +14

hm, that seems to absolutely correct.

isn't it control disabled?

check developer console for any errors, it may cause validation is not executed.

Badge +10

I need to create regular expression only to accept exact 8 numeric values.

With onprem this regular expression works fine, whereas with O365 it did not: dddddddd

BTW: it needs to be 12345678 and not 12.345.678

What is the right expression for O365?

Userlevel 7
Badge +11

Try this:

d{8}

Badge +10

Nice. That works! Thanks!

Unfortunately I still have those seperators in: 12.345.678 instead of 12345678

Userlevel 7
Badge +11

Are you saying that 12.345.678 passed that regular expression?

It didn't in my environment.  Weird.

Badge +10

In fact if you create a new item it works. When you then try to edit it, it doese not work any longer. :O

Userlevel 7
Badge +11

Hi Michael,

that's really weird. I can't seem to reproduce this.  I think you might need to reach out to Nintex Support on this one, because this is really weird behavior.

Vadim

Badge +10

I just switched column data type from "number" to "single line of text". Validation with regular expression d{8}.

Everything fine now!

Userlevel 7
Badge +11

That's awesome.  Glad it was that easy

Badge +10

Thanks for your help!

Badge +4

How do i get exactly 9 characters that includes a dot after 6 places. For example: 123456.89

Can be number or string.

Badge +5

Just what I was looking  for...

Badge +5

Is there a way to validate so that my number cannot start with or end with a zero?

Userlevel 7
Badge +11

Although I haven't tried this in Forms yet, see if this helps:

^(?!0)d+(?<!0)$

Badge +5

I got the Zeros to work...and I have the MAX digits set to 6. How to make the min 6?  I set the MAX to 6 simply using the properties in the SP column field. 

Badge +5

I figured out the MAX digits!  A previous thread.  You have to put the validation in Nintex....

Reply