Highlighted

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

Explorer ,
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.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

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

TOPICS
PDF forms, Windows

Views

417

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

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

Explorer ,
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.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

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

TOPICS
PDF forms, Windows

Views

418

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
Dec 21, 2018 0
Most Valuable Participant ,
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
Reply
Loading...
Dec 21, 2018 2
Explorer ,
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
Reply
Loading...
Dec 21, 2018 0
Explorer ,
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
Reply
Loading...
Feb 19, 2019 0
Explorer ,
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
Reply
Loading...
Feb 19, 2019 0
Explorer ,
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
Reply
Loading...
Nov 02, 2020 0
Most Valuable Participant ,
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
Reply
Loading...
Nov 02, 2020 0
Explorer ,
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
Reply
Loading...
Nov 02, 2020 0
Most Valuable Participant ,
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
Reply
Loading...
Nov 02, 2020 0
Explorer ,
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
Reply
Loading...
Nov 02, 2020 0