Skip to main content
Nintex Community Menu Bar

Counting Strings with leading zeros - validation

  • May 19, 2015
  • 9 replies
  • 30 views

Forum|alt.badge.img+4

Hi,

 

I have a little problem with Nintex Forms. I Need a Validation on a singleline textfield.

 

Here is my formular:

Length({Self}) != "5"

 

The expected length should be 5.

So here is the problem: I used a textfield. But when the user enters a number with leading zeros (00066) then Nintex Forms reduce it to 66 (only a lenth of two!). Why? I choose TEXTFIELD... Even if I add a prefix then it goes A00066 -> A66

 

Is there any way to fix this?

 

Thank you.

 

Regards

Oliver

9 replies

Forum|alt.badge.img+4

Hi Dave,

no - still the same Problem...

79242_pastedImage_0.png


vadim_tabakman
Forum|alt.badge.img+11

Hi Dave,

here's a workaround for you.

Open the text field and in the Formatting section, add a Control CSS Class name (eg. nf-TitleField).

Then expand the Validation section, and turn the Custom Validation to "Yes".

For Custom Validation Function name, put in a function name like fnTitleLengthValidation.

Save the settings, now open the Form Settings.

Expand the Custom JavaScript section and add the function below (you may need to rename it and tweak it a little to handle your function name and your class name).  I've highlighted the bits you may need to tweak to work in your environment:

function fnTitleLengthValidation(source, arguments)

{

  var myObj = NWF$('.nf-TitleField');

  if(myObj != null)

  {

    if(myObj.val().length == 5)

      arguments.IsValid=true;

    else

      arguments.IsValid=false;

  }

  else

    arguments.IsValid=false;

}

Hope this helps as a temporary workaround.

cheers,

Vadim


Forum|alt.badge.img+12
  • May 19, 2015

You can try something like this too, swap out Title with your control's Named Reference:

length(Title.toString())!=5


vadim_tabakman
Forum|alt.badge.img+11

Hey Mike,

that worked for you?  I need to try that out again, because I couldn't get that to work in my environment, which is why I ended up doing in JS.

cheers,

Vadim


Forum|alt.badge.img+12
  • May 19, 2015

Hi Vadim,

You are right, upon testing, the code I posted only works when there are numbers without leading 0000.  Good catch!

Mike


Forum|alt.badge.img+4

Hi,

thank you for your answers.

I have to do some tests. Today I will have a Workshop and I will be back tomorrow...

A few informations: trim and xxx.toString() aren't working. Still miss the zeros.

Now I have to test the java-solution.

Regards

Oliver


Forum|alt.badge.img+3
  • May 25, 2015

Try using regular expression,

80664_pastedImage_0.png


Forum|alt.badge.img+4

Hi Rohan,

this works pretty well! Thank you!

And thanks to the other one's too...

Regards

Oliver


vadim_tabakman
Forum|alt.badge.img+11

That's brilliant!!