Reputation: 16446
I've got some text that will eventually make its way into a single-line of a PDF. Because the PDF area won't have new lines to display this, I would like to use an input rather than a textarea. Inputs do not allow new lines natively and textareas require you to catch keydown events and do regex when the value changes.
Is there a way of styling an input to have it display similar to a textarea? I've tried to accomplish it with CSS but the results don't look very promising.
Upvotes: 1
Views: 99
Reputation:
In short, no. That's why textarea exists. You don't have to trap keystrokes in the textarea as it's being edited. You could simply strip the newlines after the form is submitted.
Upvotes: 0
Reputation: 7833
If you don't want to use textarea, the only way is to use a div containing the wrapped text and whenever the user clicks on it (focus) an input is shown on top that allows editing. Still, this would be pretty ugly, since the user had to edit his text in a single line.
requires CSS3
word-break: break-all;
Upvotes: 0
Reputation: 39777
You can use DIV with contentEditable
set to true
. Give this a try:
<div contenteditable="true" style="width:200px; height:200px; border:solid 1px blue; overflow:auto"></div>
Upvotes: 2