0

Here you can see the date picker but the code I used is basic.

<div class="field"> <%= label_tag("To date") %> <%= date_field_tag 'tdate', '2016/07/01', class: 'form-control' %> </div>

I don't know how date-picker is included here. I didn't worried about it until I tried to set default value '2016/07/01' to it. But as you can see in image its not appearing.

I even tried removing JQuery from application.js and bootstrap also doesn't have any class for a regular <input type= "date">.

I don't have any problem with date-picker (its very nice actually). All I need is default value to be shown.

Bootstrap classes are used for CSS. Rails 4.2.6 and ruby 2.2.4p230.

Thank you.

learner
  • 276
  • 1
  • 3
  • 16

1 Answers1

0

It is the feature of HTML5 and it follows the ISO format.

In the above code the default value has the date separator as slash "/". According to ISO format the date separator should be hyphen "-".

The below code should work.

<div class="field"> <%= label_tag("To date") %> <%= date_field_tag 'tdate', '2016-07-01', class: 'form-control' %> </div>

How to disable native date picker? (For Google chrome)

This question already asked here Disable native datepicker in Google Chrome and has an answer suggested by @Yacine Zalouani,

To hide the arrow:

input::-webkit-calendar-picker-indicator{
    display: none;
}

And to hide the prompt:

input[type="date"]::-webkit-input-placeholder{ 
    visibility: hidden !important;
}
Community
  • 1
  • 1
learner
  • 276
  • 1
  • 3
  • 16