Format of Single Line of Text field

  • 16 January 2018
  • 2 replies
  • 52 views

Badge +1

Hello,

Need some help with the format of a single line of text field using Nintex form. I need the control to be invalid if the set format is not followed. It should be in the following format (########-##-##-####). 

I was able to accomplish this in the column validation settings using the following formula: where "text" is the single line of text column:

=AND(LEN(text)=22,(MID(text,9,1)="-"),(MID(text,12,1)="-"),(MID(text,15,1)="-"),(MID(text,18,1)="-"))

However this is not allowing me to set the error message as I want when filling the form. It is throwing a generic error of something went wrong, please try again.

Any help or information is much appreciated. 

Regards,

Ronnie.


2 replies

Userlevel 5
Badge +14

you could use regular expression validation with following pattern

^d{8}-d{2}-d{2}-d{2}-d{4}$‍

212211_pastedImage_6.png

212210_pastedImage_5.png

Badge +9

Hi Ronnie,

Great question. 

Regex validation is going to be the right choice, just like Marian Hatala‌ mentioned. 

I used the following: (w{8}|d{8})[-](w{2}|d{2})[-](w{2}|d{2})[-](w{4}|d{4})

However, I also used an external JS library called Cleave.js to format the input box for me: Cleave.js - Format input text content when you are typing 

Using the following JS, I was able to enforce the formatting of the Single line text box: 

NWF$(document).ready(function () {
var cleave = new Cleave('.input-element', {
delimiter: '-',
blocks: [8, 2, 2, 4],
numeric: true
});
});

Reply