Search code examples
ruby-on-railshtmlruby-on-rails-4input-field

Placeholder in date_field_tag rails 4


I am trying to use placeholder in date_field_tag using rails 4. But instead of showing placeholder value it keeps showing 'dd-mm-yyyy'

My code

<%= date_field_tag "event_date", "", class: "form-control input-md", placeholder: "Event Date *", required: true %>

Solution

  • You can use in html format like this
    In Html
    <input placeholder="Event Date *" class="textbox-n" type="text" onfocus="(this.type='date')"  id="date"> 
    
    In Haml
    %input#date.textbox-n{:onfocus => "(this.type='date')", :placeholder => "Event Date *", :type => "text"}/