Reputation: 413
I am working on dynamic form where I have input and select tag.
with edit button
edit button
click : form will render with value
swhat exactly happening :
While click on Edit button : step num. 3 : if input field has data like
I am in first line
I am in second line
I am in third line
It rendering on form like in step 3 :
I am in first lineI am in second lineI am in third line
Question :
1. Does Input field not allowed new line?
2. If yes, I tried : style="white-space: pre-line; white-space: pre-wrap;"
, but not working
3.How to stop being removed '\n' in input field?
Thank you
Upvotes: 1
Views: 1268
Reputation: 413
I found solution using:
// this is for textarea string
var elementIdName = document.getElementById(key2);
key2Value = (elementIdName && elementIdName.tagName === "TEXTAREA") ?val.replace(/\\n/g, "<br />") : val;
Upvotes: 1