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.
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.
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 ha-zA-Z ]+.
Conclusion
When you run this form, what will it look like if you don't put the right data in the fields?
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.