Reputation: 2307
I have a textarea with input like this:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
I want an output with line breaks like this:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
How can I do that?
In my previous question, someone suggested wordwrap
, which would be useful if the line had spaces.
Upvotes: 0
Views: 117
Reputation: 1593
I don't know if I understand the question correctly, but HTML textarea field also has the wrap attribute (values "soft", "hard", or "off"). Hard wraps the words inside the text box and places line breaks at the end of each line so that when the form is submitted it appears exactly as it does in the text box.
So:
<textarea cols="30" rows="5" wrap="hard">text..</textarea>
Upvotes: 0
Reputation: 2136
you could insert a "<br /> at the index, where the break should occur - only for the output.
textbox.value = HandleLineBreaks(line, index);
Upvotes: -1