Skip to main content
jasonw51098449
Participant
July 28, 2019
Answered

How to add leading symbol in a numeric field?

  • July 28, 2019
  • 3 replies
  • 614 views

Hi!

I need to add leading symbol * in a numeric field.

Numeric field length is 10. If enter 15000,the result will be *****15,000.

Please help me out. Thanks!

This topic has been closed for replies.
Correct answer Joel Geraci

Put the following in the custom format script of the field.

The string starts with 10 asterisks then the number entered into the field gets commas inserted to separate the thousands and gets added to the 10 asterisks then we just grab the last 10 characters from the string and you get your padded value.

event.value = String("**********" + event.target.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")).slice(-10);

3 replies

jasonw51098449
Participant
August 3, 2019

Thanks! it works like a charm!

Joel Geraci
Community Expert
Joel GeraciCommunity ExpertCorrect answer
Community Expert
August 2, 2019

Put the following in the custom format script of the field.

The string starts with 10 asterisks then the number entered into the field gets commas inserted to separate the thousands and gets added to the 10 asterisks then we just grab the last 10 characters from the string and you get your padded value.

event.value = String("**********" + event.target.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")).slice(-10);

try67
Community Expert
Community Expert
July 28, 2019

You can't do that using the built-in Number format setting. You will need to write your own custom format and possibly keystroke and/or validation scripts to achieve it.