Skip to main content
Known Participant
July 19, 2024
Answered

leading zeroes

  • July 19, 2024
  • 1 reply
  • 781 views

I have text field in which I will input numbers I need something to add leading zeroes to numbers (6)
if I enter 1, field should show 000001 if I enter 1234 field should show 001234 can you help?

This topic has been closed for replies.
Correct answer Nesa Nurani

You can use this as custom format script:
if(event.value)
event.value = util.printf("%06d", event.value);

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
July 19, 2024

You can use this as custom format script:
if(event.value)
event.value = util.printf("%06d", event.value);

try67
Community Expert
Community Expert
July 19, 2024

Just be aware the above code will not change the actual field value, only the way it is displayed.
If you export or copy it, it will still be without those zeros.

MarietaaAuthor
Known Participant
July 20, 2024

Thanks, @try67, I do need to keep original value and show zeroes just for display.