The HTML shown below,
<input type="text"/>
is displayed in a browser like so:
The quick brown fox jumped over the lazy dog.
Using the HTML below,
<input type="text" value="The quick brown fox jumped over the lazy dog."/>
it is displayed in a browser like so:
That is the textarea
's job - for multiline text input. The input
won't do it; it wasn't designed to do it.
So use a textarea
. Besides their visual differences, they are accessed via JavaScript the same way (use value
property).
You can prevent newlines being entered via the input
event and simply using a replace(/\n/g, '')
.