Validation using a regular expression seems to only be available for a single line textbox control. Does anyone know a way to add a regular expression validation for a multiline textbox?
On my form the multiline textbox is used to enter library names: one on each line. I want to validate the library name on each line as they can't contain certain special characters (applicable to either the entire name or just the first character). In the workflow the information from this textbox is put into a collection and then through a for each loop to create the libraries using PowerShell.
I realize I can use a repeating section with a single textbox for each library name, but since it's just a simple set of names I thought it would look better (easier/quicker to fill out) to just use one textbox on the form - plus it simplifies the workflow (no UDA/XML queries to configure).
Solved! Go to Solution.
you can use 'custom validation' option and validate text box content against regex pattern within simple javascript function.
Hi Marian,
I have yet to learn more about using JavaScript for Nintex. How would I go about adding a regex pattern via JavaScript?
Thanks!
something like this might work for you
configure validation function and validation message on MLTB control
in form settings define your validation function
this one will cause validation not to pass through if MLTB control contains either of capital A or B or C
function ValidateMLTB(ctrl, args){
args.IsValid = !String(args.Value).match(/[ABC]/);
}
Thank you, that's really helpful.
I added the pattern [^A-Za-z0-9\s\.] to allow for these characters and none of the others (*, %, -, /, & and so on). This seems to work.
However there's one more requirement: a dot or space are allowed in the library name but not at the beginning of a name - i.e. the beginning of every line in a multiline textbox. I tried putting ^\s\. outside of the brackets, but can't make it work. Do you have the solution for me?
Brilliant!!!
Brilliant indeed! Thank you!!
I realized I need to allow for accented (diacritical) characters as well. These are not supported in the above regex.
I did some Googling and thought about adding À-ÿ but this then also allows for the characters \, _ and ^. When I use something like \u00C0-\u024F this problem is solved, but then an Enter (blank line) is allowed on the last line of a row. I also couldn't make it work with something like this: \p{L}\p{M}
Do you have any more suggestions for me?
wouldn't pattern ^$ work to rule out empty lines?