0

Hello I have a problem with the datepicker. I see the days and not only the months I mean instead of having this :

datepicker

I get this :

datepicker

Here is my code :

 <input type="text" id="datepicker" />

and here is the js :

$("#datepicker").datepicker( {
    format: "mm-yyyy",
    viewMode: "months", 
    minViewMode: "months"
});

Could you help me please ?

Thank you very much !

Peter
  • 123
  • 5

2 Answers2

0

Try this.

$(document).ready(function(){

    $("#datepicker-month").datepicker( {
        format: "mm-yyyy",
        viewMode: "months", 
        minViewMode: "months"
    });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>


<input type="text" id="datepicker-month" />
souravmsh
  • 638
  • 6
  • 11
0

Hope this will help you:

$('#you-date-picker-element').datepicker({
    autoclose: true,
    minViewMode: 1,
    orientation: 'left',
    container: '.your-date-picker-container',
    format: 'M-yyyy'
}).on('changeDate', function(selected){
    startDate = new Date(selected.date.valueOf());
    startDate.setDate(startDate.getDate(new Date(selected.date.valueOf())));
    $('#your-field-name').datepicker('setStartDate', startDate);
}); 
Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
Prajan Karmacharya
  • 373
  • 1
  • 4
  • 13