在MONTH视图中禁用bootstrap dateTIMEpicker中的某些月份

时间:2017-03-28 14:05:12

标签: datetimepicker bootstrap-datetimepicker

我正在尝试在dateTIMEpicker中禁用月份,而不是在月份模式下的datepicker(并且需要保持该模式)。

我需要禁用的月份是datePickerFrom之前的月份。

这是我的代码:

$('#newDialog #datePickerFrom').datetimepicker({
        format: 'dd.MM.yyyy',
        viewMode: 'months',
        minViewMode: 'months',
        pickTime: false
    });

$('#newDialog #datePickerTo').datetimepicker({
        format: 'dd.MM.yyyy',
        viewMode: 'months',
        minViewMode: 'months',
        pickTime: false
    });

    $('#newButton').click(function() {
        var dialog = $('#newDialog');
        $('#dialogHeader').text("New monthly fee");

        resetValue($("#id", dialog), '');
        resetValue($("#countryId", dialog), '');
        resetValue($("#typeId", dialog), '');
        resetValue($("#currencyId", dialog), '');
        resetValue($("#reportChannelTypeId", dialog), '');
        resetValue($("#value", dialog), '0.00');
        resetValue($("#description", dialog), '');
        resetValue($("#validTo", dialog), '');

        var date = new Date();
        var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
        var pickerFrom = $('#newDialog #datePickerFrom').data('datetimepicker');
        firstDay.setHours(0, 0, 0, 0);
        pickerFrom.setLocalDate(firstDay);

        $('#newDialog #datePickerTo').datetimepicker().on("changeDate", function(e) {
            var endDay = new Date(e.date.getFullYear(), e.date.getMonth() + 1, 0);
            var pickerEnd = $('#newDialog #datePickerTo').data('datetimepicker');
            endDay.setHours(23,59,59,999);
            pickerEnd.setLocalDate(endDay);
        });

0 个答案:

没有答案