Copy link to clipboard
Copied
I have a serial number log form (PDF) where the first serial number entered will be 0001 (it shows the leading zeros in the first text box. Formatting set to NONE ) and there after increment the following text box by 1. The calculation to increment by 1 is not the issue. I cant seem to format the text box to show the leading zeros. The second serial number comes out as "2" not "0002" as I would liked.
I take it that I'm going to need some type of "Format" java script here to get the leading Zeros to show up?
Copy link to clipboard
Copied
Can you post the code you're using? A small adjustment to it should be enough.
Copy link to clipboard
Copied
The calculation does turn a string containing numbers into a number. That's why the leading zeroes disappear.
To get them back, we can use a Custom format, using the util.printf() method.
In the case here, you would add the following to the Format event of the field:
event.value = util.printf("%04d", event.value) ;
and that should do it; the number (4) stands for the number of digits in total.
Copy link to clipboard
Copied
Johnny, your solution is the most simplest and elegant solution. Thank you. I was messing around for hours with If/else if.etc. Finding out that JS can't get the length of a number unless it's a string (was trying to use LEN/.length to determine if single digit), I saw all these other solutions and my gosh, yours? ONE LINE! AWESOME! Thanks again