cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Insert zero automatically

Hi Friends,

 

I have requirement, where "0" has to be inserted automatically if the number I entered is a two digit number. Is there any way we can use regular expressions to do that? So for ex.: if I type as 20, the output should be 020 and if I type 234, the output should be 234 only.

 

Is it possible?

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

Re: Insert zero automatically

Hi ChandraShekhar Rameneni​,

You could use rules in the Nintex Forms to do so.

  1. First click on the text box on which you have to apply this rule.
  2. Then click on rules option in the ribbon.
  3. Select add new rule.
  4. Here in the rule section you can define your regex according to your rule.
0 Kudos
Accept as Solution Reply
Not applicable

Re: Insert zero automatically

Hi Ratnesh, thanks for the input. Can you please suggest the regex to get my desired output?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Insert zero automatically

Alternatively,you should be able to achieve this using javascript

1. add unique css class name to your input control

2. add custom javascript so that when the input value changes (keyup function is what you want here) it will append 0 in front of it when its 2 digits. In the following example you should use 2 as your max value

function pad (str, max) {
  str
= str.toString();
 
return str.length < max ? pad("0" + str, max) : str;
}

pad
("3", 3);   // => "003"
pad
("123", 3);  // => "123"
pad
("1234", 3); // => "1234"

http://stackoverflow.com/questions/6466135/adding-extra-zeros-in-front-of-a-number-using-jquery

0 Kudos
Accept as Solution Reply