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.
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.";
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.";
Copy link to clipboard
Copied
Thanks! It works.
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
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
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;
Copy link to clipboard
Copied
event.value = "Thank you for your submission, " + this.getField("Your Name").valueAsString;
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.
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;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Change this:
if (textField="-")
To:
if (/-/.test(textField))
And use it as the custom calculation script.
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
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
I put the script in the PDF -> Text Field Properties -> Calculate Tab -> Custom Calculation Script
Copy link to clipboard
Copied
At what field?
Copy link to clipboard
Copied
Field Name: This.#PropCov.CustomNumber38
Copy link to clipboard
Copied
Replace
this.getField("This.#PropCov.CustomNumber38").valueAsString
with
event.value
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.
Copy link to clipboard
Copied
Why have you replaced only one entry?
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.
Copy link to clipboard
Copied
Enter a minus sign and you will get +-
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
To compare use double ==
if(textField =="-"...
Copy link to clipboard
Copied
I tried that as well and it still didn't work.


-
- 1
- 2