Bootstrap Datepicker - Months and Years Only

后端 未结 8 1528
逝去的感伤
逝去的感伤 2020-12-02 07:07

I am using bootstrap datepicker and my code is like following, Demo of the code on jsfiddle

相关标签:
8条回答
  • 2020-12-02 07:48

    I'm using version 2(supports both bootstrap v2 and v3) and for me this works:

    $("#datepicker").datepicker( {
        format: "mm/yyyy",
        startView: "year", 
        minView: "year"
    });
    
    0 讨论(0)
  • 2020-12-02 07:53

    Notice that in the version of 1.2.0 the viewMode has changed to startView.

    eg:

    $('#sandbox-container input').datepicker({
      startView: 1,
      minViewMode: 1
    });
    

    http://eternicode.github.io/bootstrap-datepicker/?markup=component&format=yyyy&weekStart=&startDate=&endDate=&startView=2&minViewMode=2&todayBtn=false&language=zh-CN&orientation=auto&autoclose=on&forceParse=on#sandbox

    0 讨论(0)
  • 2020-12-02 07:54

    Para visualiar los meses del año actual,visualiza solo los meses, y con el formato solo toma los meses de ese año. tambien se puede confirurar para que se visualice una cierta cantidad de meses

    <script>
    ('#txtDateMMyyyy').datetimepicker({
        format: "mm/yyyy",
        startView: "year",
        minView: "year"
    }).datetimepicker("setDate", new Date());
    </script>
    
    0 讨论(0)
  • 2020-12-02 08:02

    I am using bootstrap calender for future date not allow with allow change in months & year only..

    var j = jQuery.noConflict();
            j(function () {
                j(".datepicker").datepicker({ dateFormat: "dd-M-yy" }).val()
            });
    
            j(function () {
                j(".Futuredatenotallowed").datepicker({
                    changeMonth: true,
                    maxDate: 0,
                    changeYear: true,
                    dateFormat: 'dd-M-yy',
                    language: "tr"
                }).on('changeDate', function (ev) {
                    $(this).blur();
                    $(this).datepicker('hide');
                }).val()
            });
    
    0 讨论(0)
  • 2020-12-02 08:02

    Why not call the $('.input-group.date').datepicker("remove"); when the select statement is changed then set your datepicker view then call the $('.input-group.date').datepicker("update");

    0 讨论(0)
  • 2020-12-02 08:07

    For the latest bootstrap-datepicker (1.4.0 at the time of writing), you need to use this:

    $('#myDatepicker').datepicker({
        format: "mm/yyyy",
        startView: "year", 
        minViewMode: "months"
    })
    

    Source: Bootstrap Datepicker Options

    0 讨论(0)
提交回复
热议问题