Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

line breaks in form element input value

I am trying to add line breaks (aka newlines) to values of the input-element. 
, 
, 
 
 and \n aren't working; still everything is on one line.

I haven't found an answer to this question amongst other questions that solves my problem. Thanks in advance.

like image 917
DanMad Avatar asked Mar 12 '17 04:03

DanMad


People also ask

How do you insert a line break in input field?

To add line breaks to a textarea, use the addition (+) operator and add the \r\n string at the place where you want to add a line break, e.g. 'line one' + '\r\n' + 'line two' . The combination of the \r and \n characters is used as a newline character. Here is the HTML for the examples in this article. Copied!

What are line breaks in code?

Also called "EOL" (end-of-line), "newline," and "hard return," a line break code is generated when the Enter key is pressed, When typing a command on a command line, pressing Enter executes the command.

How do you show line breaks in HTML?

Note: Use the <br> tag to enter line breaks, not to add space between paragraphs.

How do you create a line break?

Press ALT+ENTER to insert the line break.


2 Answers

I don't actually think you can have line breaks for those types of form elements. You may have to use a <textarea> tag which allows for literal line breaks:

<textarea id="multiliner" name="multiliner">line1
line2
line3</textarea>
like image 190
dana Avatar answered Oct 19 '22 06:10

dana


The HTML input elements, type text or something similar (such as email) will deliberately strip off all line breaks, so that’s not going to work.

The only form element which will accept line breaks is the textarea.

Incidentally, Clipboard.js works by creating a dummy textarea element to do its magic.

like image 36
Manngo Avatar answered Oct 19 '22 08:10

Manngo