How can I display numerics only, with a comma, and no decimal spaces can be entered?

Dec 09, 2018

Copy link to clipboard

Copied

Hi all,

I'm currently using 2 types of script that essentially do the same thing perfectly, however, I want to also display the comma for large numbers:

Here's script 1:

if(!event.willCommit)

event.rc = /^\d*$/.test(event.change);


Here's script 2:

var reg = /^\d*$/;

event.rc = reg.test(event.value);

Does anyone know how I can add the comma to the scripts above or a new one do this?

Also note, I've already tried using the basic "number" in the format tab, but I do not want to display or allow the user to enter any decimals - so it has to be custom keystroke script I think.

Screen Shot 2018-12-10 at 12.49.11 pm.jpg

The example above displays 8000 but I want it to display 8,000, I want the user to only be able to enter numerics and no other characters, or decimals (whole number only).


Any info would be appreciated
Thanks!

Alex

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

100

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 can I display numerics only, with a comma, and no decimal spaces can be entered?

Dec 09, 2018

Copy link to clipboard

Copied

Hi all,

I'm currently using 2 types of script that essentially do the same thing perfectly, however, I want to also display the comma for large numbers:

Here's script 1:

if(!event.willCommit)

event.rc = /^\d*$/.test(event.change);


Here's script 2:

var reg = /^\d*$/;

event.rc = reg.test(event.value);

Does anyone know how I can add the comma to the scripts above or a new one do this?

Also note, I've already tried using the basic "number" in the format tab, but I do not want to display or allow the user to enter any decimals - so it has to be custom keystroke script I think.

Screen Shot 2018-12-10 at 12.49.11 pm.jpg

The example above displays 8000 but I want it to display 8,000, I want the user to only be able to enter numerics and no other characters, or decimals (whole number only).


Any info would be appreciated
Thanks!

Alex

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

101

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
Dec 09, 2018 0

Have something to add?

Join the conversation