I am creating a custom pdf form using JavaScript custom calculations and I want to add a text field with two lines separated by a newline character. I use this.getField() to get values from multiple text boxes. Then I want to join two of them into one text field separated by a new line. I can join the two strings and pass it into the text field but as soon as I add '\t' or '\n' to the string it won't show up in the text field. If I use the JavaScript console to call the value of the string it shows up correctly but I can't figure out why it the text filed shows up blank.
Asked
Active
Viewed 1,165 times
1 Answers
0
You can try using the ASCII representation of carriage returns, String.fromCharCode(13)
:
string += "Carriage return comes after this " + String.fromCharCode(13);
This is discussed in more detail here. I found that answer by googling "insert newline into text field javascript string"

Community
- 1
- 1

Marty Cortez
- 2,325
- 1
- 17
- 22
-
I tried this and I can't seem to get it to work. It shows up in the JavaScript console formatted correctly but still doesn't show up in my text field. – jbcampbell21 Sep 18 '13 at 17:53
-
1I finally figured it out. I had the properties set in the text field menu set to multiline but I had to set the field to multiline with Javascript. field.multiline= true; – jbcampbell21 Sep 18 '13 at 18:57
-
Maybe you should post that as the answer? – Marty Cortez Sep 18 '13 at 23:29