cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Counting Strings with leading zeros - validation

Jump to solution

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

Labels: (2)
0 Kudos
Reply
11 Replies
Not applicable

Re: Counting Strings with leading zeros - validation

Jump to solution

Hi Oliver,

I had a play with this and i think i have found the problem.

The Length function seems to convert your String to a Number for some reason (i will try and find out more - edit: i found the validation failed with ANY number actually...)

Further testing showed me i was incorrect in my solution apologies, i will continue

Edit2: I forgot to Credit Vadim Tabakman post in Running inline function in a string with comma for the answer...Vadim Tabakman

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

Hi Dave,

no - still the same Problem...

0 Kudos
Reply
Not applicable

Re: Counting Strings with leading zeros - validation

Jump to solution

Hi Oliver,

I think i have it now...

length(trim({Self}))!=5

that seems to work for my side.

Question: Is the List column type number or text?

Thanks,

Dave

edit: nope, the length function now ignores numbers almost completely?

edit2: this might help, i cannot get it to work on my side but it seems to be a known issue... Validate field for length or blank

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

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

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

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

length(Title.toString())!=5

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

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

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

Hi Vadim,

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

Mike

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

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

0 Kudos
Reply
Workflow Hero

Re: Counting Strings with leading zeros - validation

Jump to solution

Try using regular expression,

Reply