count character and add text to location

New Here ,
Jun 14, 2019 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

TOPICS
Acrobat SDK and JavaScript

Views

86

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Jun 14, 2019 Jun 14, 2019
Here's a simple general purpose script for thisevent.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

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

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

translate

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
community guidelines