count character and add text to location

New Here ,
Jun 14, 2019

Copy link to clipboard

Copied

I am trying to count the number of numbers and add a + symbol to the second to last value in form field

example

user input into field 1000

form format 10+00

user input into field 10000

form format 100+00

user input into field 100000

form format 1000+00

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Here's a simple general purpose script for this

event.value = event.value.replace(/(\d\d)$/,"+$1");

If you want to change the actual value of the field, this script should be placed in the validation or "WillCommit" event script.

If you just want to change how the field is displayed to the user, then it should be placed in the Format Script.

TOPICS
Acrobat SDK and JavaScript

Views

80

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

count character and add text to location

New Here ,
Jun 14, 2019

Copy link to clipboard

Copied

I am trying to count the number of numbers and add a + symbol to the second to last value in form field

example

user input into field 1000

form format 10+00

user input into field 10000

form format 100+00

user input into field 100000

form format 1000+00

Adobe Community Professional
Correct answer by Thom Parker | Adobe Community Professional

Here's a simple general purpose script for this

event.value = event.value.replace(/(\d\d)$/,"+$1");

If you want to change the actual value of the field, this script should be placed in the validation or "WillCommit" event script.

If you just want to change how the field is displayed to the user, then it should be placed in the Format Script.

TOPICS
Acrobat SDK and JavaScript

Views

81

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
Jun 14, 2019 0
Adobe Community Professional ,
Jun 14, 2019

Copy link to clipboard

Copied

Here's a simple general purpose script for this

event.value = event.value.replace(/(\d\d)$/,"+$1");

If you want to change the actual value of the field, this script should be placed in the validation or "WillCommit" event script.

If you just want to change how the field is displayed to the user, then it should be placed in the Format Script.

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...
Jun 14, 2019 0