How to add leading symbol in a numeric field?

New Here ,
Jul 27, 2019

Copy link to clipboard

Copied

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!

Adobe Community Professional
Correct answer by Joel_Geraci | Adobe Community Professional

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);

TOPICS
Acrobat SDK and JavaScript

Views

125

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to add leading symbol in a numeric field?

New Here ,
Jul 27, 2019

Copy link to clipboard

Copied

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!

Adobe Community Professional
Correct answer by Joel_Geraci | Adobe Community Professional

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);

TOPICS
Acrobat SDK and JavaScript

Views

126

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 27, 2019 0
Most Valuable Participant ,
Jul 28, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 28, 2019 0
Adobe Community Professional ,
Aug 02, 2019

Copy link to clipboard

Copied

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);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2019 1
New Here ,
Aug 03, 2019

Copy link to clipboard

Copied

Thanks! it works like a charm!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2019 0