Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Is it possible to append a text to an input field?

Explorer ,
Dec 21, 2018 Dec 21, 2018

Copy link to clipboard

Copied

I would like to know if it is possible to append a text to an input field.

Example:

I have an input field, say "Weight"

What I would like to happen is when the user input 170, the field will display "170 lbs.". The "lbs." is appended to the value that is inputted in the field.

TOPICS
PDF forms, Windows

Views

1.8K

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

correct answers 1 Correct answer

Adobe Community Professional , Dec 21, 2018 Dec 21, 2018
Sure, that's possible. Use this code as the field's custom Format script:if (event.value) event.value += " lbs.";

Likes

Translate

Translate
Adobe Community Professional ,
Dec 21, 2018 Dec 21, 2018

Copy link to clipboard

Copied

Sure, that's possible. Use this code as the field's custom Format script:

if (event.value) event.value += " lbs.";

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
community guidelines
Explorer ,
Dec 21, 2018 Dec 21, 2018

Copy link to clipboard

Copied

Thanks! It works.

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
community guidelines
Explorer ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

I tried this solution and first time I input a value, the text "lbs." is appended to my input.

However, when I go and enter value in another field, another "lbs." is appended so it now looks like "34 lbs. lbs.". The "lbs." keep on appending every time I enter values in other fields.

This happened only when you first enter value to this field and proceed entering values to other fields in the same form. But if its the last field your fill-out, it ok.

Please help me out here.

Thanks

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
community guidelines
Explorer ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

Please ignore this posting. I was able to realized my error. I should have put the script in Validate > Run Custom Validation Script. Sorry

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
community guidelines
Explorer ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

I'm trying to do something similar, but in reverse order.  How do I modify the script example above to insert "Thank you for your submission, " + field name ("Your Name")?

 

My current script is: event.value = this.getField("Your Name").valueAsString;

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
community guidelines
Adobe Community Professional ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

event.value = "Thank you for your submission, " + this.getField("Your Name").valueAsString;

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
community guidelines
Explorer ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

Thank you for the reply.  However the text "Thank you for your submission, " automatically displays when the form opens and before the user enters their name.  I want that text string to populate, along with the user's entry of their name to come up after the user enters his/her name.

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
community guidelines
Adobe Community Professional ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

Use this:

 

var name = this.getField("Your Name").valueAsString;
if (name=="") event.value = "";
else event.value = "Thank you for your submission, " + name;

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
community guidelines
Explorer ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

Thank you. Works perfectly.

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
community guidelines
New Here ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

Can someone help me with my issue that is similar?  If the text includes a "-" (negative sign) then just use the value of that field, otherwise, add a "+" before the field value. 

 

var textField = this.getField("This.#PropCov.CustomNumber38").valueAsString;

 

if (textField="-") event.value = this.getField("This.#PropCov.CustomNumber38").valueAsString;
else event.value = "+" + this.getField("This.#PropCov.CustomNumber38").valueAsString

 

Also - I have been adding this to my "Format", "Validate" and "Calculate" fields - but I do not think that is correct.

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
community guidelines
Adobe Community Professional ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

Change this:

if (textField="-")

To:

if (/-/.test(textField))

And use it as the custom calculation 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
community guidelines
New Here ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

I tried that and still didn't work.

 

var textField = this.getField("This.#PropCov.CustomNumber38").valueAsString;

if (/-/.test(textField)) event.value = this.getField("This.#PropCov.CustomNumber38").valueAsString;
else event.value = "+" + this.getField("This.#PropCov.CustomNumber38").valueAsString

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
community guidelines
Adobe Community Professional ,
Jun 02, 2021 Jun 02, 2021

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
community guidelines
New Here ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

I put the script in the PDF -> Text Field Properties -> Calculate Tab -> Custom Calculation 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
community guidelines
Adobe Community Professional ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

At what field?

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
community guidelines
New Here ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Field Name: This.#PropCov.CustomNumber38

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
community guidelines
Adobe Community Professional ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Replace
this.getField("This.#PropCov.CustomNumber38").valueAsString
with
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
community guidelines
New Here ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Like this?

var textField = this.getField("This.#PropCov.CustomNumber38").valueAsString

if (textField=="-") event.value = this.getField("This.#PropCov.CustomNumber38").valueAsString;
else event.value = "+" + event.value;

 

What I am expecting is IF the value has a Negative (-) sign like this -1443, THEN it will just be 1443. IF it doesn't have a Negative sign then it will add a Plys (+) sign to the value instead. 

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
community guidelines
Adobe Community Professional ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Why have you replaced only one entry?

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
community guidelines
New Here ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Replaced all and now this is how it looks:

 

var textField = event.value

if (textField=="-") event.value = "+" + event.value
else event.value = "-" + event.value;

 

I guess I am still doing something wrong, still not working.

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
community guidelines
Adobe Community Professional ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Enter a minus sign and you will get +-

 

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
community guidelines
Adobe Community Professional ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

LATEST

This line of code:

if (textField=="-")

Means "if textField equals '=' EXACTLY".

It will return false if the value of textField is "-1446", for example.

That's why I fixed it for you in my original reply, which would solve this problem.

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
community guidelines
Adobe Community Professional ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

To compare use double ==

if(textField =="-"... 

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
community guidelines
New Here ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

I tried that as well and it still didn't work. 

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
community guidelines
    • 1
    • 2