I need to crate validation for a single line of text column. The validation required is to count the total number of characters( Text and Numbers) entered amd validate that 7 items were entered.
When someone enters in their ID take "JN76161" for example I want the column to validate that they entered a total of 7 characters. No more no less.
If we can also validate so that it requires that the first two characters are text that would be awesome too.
Thanks,
Jacob
Solved! Go to Solution.
Hi Jacob,
for the length check you can use a simple validation rule:
This rule checks how many characters have been entered in the textbox and will only allow to submit the form if 7 characters have been entered.
For the check of the first two letters, you will probably need a little more effort. My idea would be to use a regular expression in javascript (unless there a runtime function for regexs I'm missing?!). Go to the settings of the control and add a javascript variable name so you can reference your field in your javascript code.
Here is a reference for how to implement simple javascript into nintex form: Re: Nintex Forms and JavaScript basics
And here is a reference for using regular expressions in javascript: https://wiki.selfhtml.org/wiki/JavaScript/Objekte/RegExp
And last but not least something usefull to create/test regular expressions: Online regex tester and debugger
Cheers
Philipp
using regular expression validation you may ensure both your requirements for length and starting with two (uppercase?) chars by following expression
[A-Z]{2}\d{5}$
Use regular expression in control settings:
Thank you Manfred, your regular expression worked.
Now, associates are allowed to type their ID either uppercase or lowercase. That being said I had to add.....
((^|, )(part1|part2))+$ I added your expression in part1 and part2 only changing the [a-z] to [A-Z].
((^|,)(^[a-z]{2,2}\d{5,5}$|^[A-Z]{2,2}\d{5,5}$))+$
It now accepts.... JN76161 or jn76161, but not JN7616 or jn7616.
Thank you,
Jacob
Phillip,
Thank you for your quick response. Unfortunately I couldn't get your way to work.
I was able to use regular expressions explained by Manfred Lauer below.
Thanks,
Jacob
Manfreds suggestion is certainly the better way. I forgot you can use regex directly in the control settings.
Cheers
Philipp
You wanted to match 5 digits. So what You mean by 'but not JN7616 or jn7616'?
To match first 2 characters either lower or upper case use:
^([a-z]{2}|[A-Z]{2})\d{5,5}$
To match first 2 characters mixed case use:
^[a-zA-Z]{2,2}\d{5,5}$
Oh sorry, no it works exactly how you sent it to me. I was just going into greater detail for those reading the forum. I simply was clarifying that it works because it fails when I type more than 5 or less than 5.
I understand that your suggested reg. requires the exact format...
However, how can I make it so it request the "minimum" and maximum in following format:
minimum: ABCD.12345
maximum: ABCD.12345.12.123
What can go through examples:
ABCD.12345
ABCD.12345.12
ABCD.12345.12.123