5

I have a textarea which is has Markdown support and I would like to show a placeholder to show what sort of formatting Markdown likes but putting <br /> in the placeholder shows <br /> in the text. I would prefer it to make a new line if this is possible.

I am using Rails 3, below is the code I am using:

<%= f.text_area :info, :placeholder => "if you want you can <br /> add a link by doing this: [text](http://link.com) it's pretty neat aye? or you could use bold by doing this: **bold text is cool**" %>

3 Answers3

0

As Logan says, though you can find some hacks in the similar question here:

Can you have multiline HTML5 placeholder text in a <textarea>?

Community
  • 1
  • 1
lobati
  • 9,284
  • 5
  • 40
  • 61
0

Here are some more related hacks to multiline placeholders, I followed the example in the answer below to do my workaround: Insert line break inside placeholder attribute of a textarea?

For rails, I thought this was useful if you want a gem to deal with placeholders: jquery-placeholder-rails.

However, you'll need the forked version of jQuery-placeholder that supports newline: jQuery-Placeholder-Newlines

Community
  • 1
  • 1
T.Ng
  • 31
  • 4
0

According to the specification, the placeholder attribute can't contain any line breaks or carriage returns.

Logan Leger
  • 662
  • 3
  • 10