Ruby on Rails : HTML :: Multiline placeholder in textarea

Note: String must be inside “double quotes”

 <%= f.text_area :address, placeholder:"Street\r\nCity\r\nState, Zip"

This style of multi-line placeholder works fine in safari, Google Chrome and Browsers derived from Google Chrome. How ever this is not the case in firefox and IE. So have multi-line placeholders in these browser we have to use the JS way.

There is a jQuery plugin to do this job. Luckly, RubyOnRails’s gem for this plugin is also avilable here

jquery-placeholder-rails

or you can use the jQuery plugin itself

HTML5 Placeholder jQuery Plugin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s