• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Adding @ symbol in front of a number

Explorer ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

I have a form field in which a 4-digit number is entered, and:

1.  Upon exiting the field would like the @ symbol to appear at the beginning of the 4-digit number:  Type "1234" and diplay "@1234"

2.  If the form field is blank (not used) then the @ symbol does not appear.

TOPICS
Acrobat SDK and JavaScript

Views

783

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 2 Correct answers

Community Expert , Nov 30, 2020 Nov 30, 2020

Try this as validation script:

event.value = event.value != "" ? "@"+event.value : "";

Votes

Translate

Translate
Community Expert , Dec 07, 2020 Dec 07, 2020

How are you changing numbers in field?

It will give you duplicate if when changing number manually you change only number and not @ .

As sugested by @JR Boulay  move script to custom format script.

 

Votes

Translate

Translate
Community Expert ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

Try this as validation script:

event.value = event.value != "" ? "@"+event.value : "";

Votes

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
Community Expert ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

It would be best used as a "Format" script

😉

Votes

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
Explorer ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

Thank you, that worked perfect!

Votes

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
Explorer ,
Dec 06, 2020 Dec 06, 2020

Copy link to clipboard

Copied

When I enter:

event.value = event.value != "" ? "@"+event.value : "";

It works perfect, but each time I modify a number in the field it adds an additional @ symbol to the beginning (i.e. @理菜山58955789, @@2345, @@@3456, etc.).  Other than deleting the displayed @ sybmol in the field each time I change the number, is there a way to stop extra @ symbols from repeating?

Votes

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
Contributor ,
Nov 30, 2020 Nov 30, 2020

Copy link to clipboard

Copied

I'm not the brightest in Adobe, but I can remember that you can format it with a text field.

Steps for Adobe Pro DC

Prepare form,

go to text field,

Right mouse click,

Choose properties,

Options,

Enter standard value,

insert the character "@",

Conclude.

 

So it should appear every time you click on the field.

I am sure that there are more suggested solutions, but this is easy and quick.

 

I hope I could help you.

If that's not what you want, just ignore it.

 

Thx

Nikolaos.

Votes

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
Explorer ,
Dec 06, 2020 Dec 06, 2020

Copy link to clipboard

Copied

When I enter:

event.value = event.value != "" ? "@"+event.value : "";

It works perfect, but each time I modify a number in the field it adds an additional @ symbol to the beginning (i.e. @1234, @@2345, @@@3456, etc.).  Other than deleting the displayed @ sybmol in the field each time I change the number, is there a way to stop extra @ symbols from repeating?

Votes

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
Community Expert ,
Dec 06, 2020 Dec 06, 2020

Copy link to clipboard

Copied

Where does you use the script?

Votes

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
Community Expert ,
Dec 07, 2020 Dec 07, 2020

Copy link to clipboard

Copied

LATEST

How are you changing numbers in field?

It will give you duplicate if when changing number manually you change only number and not @ .

As sugested by @JR Boulay  move script to custom format script.

 

Votes

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