Why Is Textarea Filled with Mysterious White Spaces

Why is textarea filled with mysterious white spaces?

Look closely at your code. In it, there are already three line breaks, and a ton of white space before </textarea>. Remove those first so that there are no line breaks in between the tags any more. It might already do the trick.

Why is textarea filled with mysterious white spaces?

Look closely at your code. In it, there are already three line breaks, and a ton of white space before </textarea>. Remove those first so that there are no line breaks in between the tags any more. It might already do the trick.

Default Value TextArea Mysterious Spaces

You have indentations in the html. ANYTHING that appears between the opening/closing <textarea> tags becomes PART of the text area:

<div class="col-sm-12">
<textarea name="description" class="form-control" rows="5" placeholder="Desciption">
^
{{$description}}
^^^^^^^^ ^
</textarea>
^^^^
</div>

The ^ mark the spaces you're getting. If you don't want those spaces, then don't have them:

<textarea>foo</textarea>

v.s.

<textarea>
^--line break at start of textarea content
foo
^^^^----spaces
^--another line break
</textarea>

Textarea has mysterious whitespace

Content in #song-title element must have new lines.

Given:

<div id="song-title">
Pieces - Red
</div>

$("#song-title").text(); would return:

"
Pieces - Red
"

Textarea with white space detect

HTML itself does not provide a "preview" for textareas. However, if you submit it to a PHP script you can use nl2br() to convert linebreaks into html linebreaks.

Before doing so you need to use htmlspecialchars() to escape HTML tags unless everyone using that form is trusted enough to enter arbitrary html.



Related Topics



Leave a reply



Submit