Adding @ symbol in front of a number

Community Beginner ,
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.

Try this as validation script:

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

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

55

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

Adding @ symbol in front of a number

Community Beginner ,
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.

Try this as validation script:

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

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

56

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

Copy link to clipboard

Copied

Try this as validation script:

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

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...
Nov 30, 2020 1
Adobe Community Professional ,
Nov 30, 2020

Copy link to clipboard

Copied

It would be best used as a "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...
Nov 30, 2020 0
Community Beginner ,
Nov 30, 2020

Copy link to clipboard

Copied

Thank you, that worked perfect!

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...
Nov 30, 2020 0
Community Beginner ,
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?

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...
Dec 06, 2020 0
Participant ,
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.

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...
Nov 30, 2020 0
Community Beginner ,
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?

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...
Dec 06, 2020 0
Adobe Community Professional ,
Dec 06, 2020

Copy link to clipboard

Copied

Where does you use the 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...
Dec 06, 2020 0
Enthusiast ,
Dec 07, 2020

Copy link to clipboard

Copied

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.

 

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...
Dec 07, 2020 0