1

I'm using an input of the type date. I would like to know if there is a way to make the datepicker selection panel opened by default when the user enters in the page.

The element look like this:

<input class="form-control user-success" id="starting-date" name="date" required="" type="date" value="2017-04-07" data-initialized="true">
Tiago Neto
  • 379
  • 1
  • 3
  • 15
  • Possible duplicate of [Open HTML5 date picker on icon click](http://stackoverflow.com/questions/18326982/open-html5-date-picker-on-icon-click) – Raidri Apr 07 '17 at 08:46
  • Not a direct duplicate but the answer explains that it is not possible for a html input date element. – Raidri Apr 07 '17 at 08:47

3 Answers3

0

Did you try adding autofocus

<input class="form-control user-success" id="starting-date" name="date" required="" type="date" value="2017-04-07" data-initialized="true" autofocus="autofocus">
  • Using the autofocus, the datepicker will be focused by default. But what I want to do is making the selection panel opened by default – Tiago Neto Apr 07 '17 at 08:52
0

By using following funtion date picker will open bydefault after screen load.

$(function() {
    $( "#starting_date" ).datepicker();
    $( "#starting_date" ).datepicker("show");
 });
Jigar Bhatt
  • 4,217
  • 2
  • 34
  • 42
-1

You can display it embedded in a webpage by calling it on div instead of input, as per official documentation.

  • In this case I can't use any other libraries than Jquery. So using JqueryUI is out of question – Tiago Neto Apr 07 '17 at 08:51
  • You don't use the Datepicker? You won't achieve it with html only. –  Apr 07 '17 at 08:55
  • I can use JQuery, but nothing besides that – Tiago Neto Apr 07 '17 at 08:58
  • As I said you won't achieve it with jQuery and html only. You would have to create your own calendar from scratch, open that on page load and use it to change the input values. –  Apr 07 '17 at 09:01