美文网首页
datapicker option日期区间

datapicker option日期区间

作者: Mr_Laoyu | 来源:发表于2018-12-18 10:41 被阅读0次

    一、uxsolutions

    github:https://github.com/uxsolutions/bootstrap-datepicker
    doc:https://bootstrap-datepicker.readthedocs.io/en/stable/index.html
    I18N:要引入语言包

    $('#datetimepicker1').datepicker({
        format: "yyyy-mm-dd",
        language: 'zh-CN',
        autoclose: true,
        endDate:new Date()
    }).on('changeDate', function(ev){               
        if(ev.date){
            $('#datetimepicker2').datepicker('setStartDate', new Date(ev.date.valueOf()))
        }else{
            $('#datetimepicker2').datepicker('setStartDate',null);
        }
    });
    
    $('#datetimepicker2').datepicker({
        format: "yyyy-mm-dd",
        language: 'zh-CN',
        autoclose: true,
        endDate:new Date()
    }).on('changeDate', function(ev){               
        if(ev.date){
            $('#datetimepicker1').datepicker('setEndDate', new Date(ev.date.valueOf()))
        }else{
            $('#datetimepicker1').datepicker('setEndDate',null);
        }
    });
    

    二、Eonasdan

    github:https://github.com/Eonasdan/bootstrap-datetimepicker
    doc:http://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers

    $('#datetimepicker1,#datetimepicker2').datetimepicker({
        format: "YYYY-MM-DD",
        locale: 'zh-cn'
    });
    
    $("#datetimepicker1").on("dp.change", function (e) {
        $('#datetimepicker2').data("DateTimePicker").minDate(e.date);
    });
    $("#datetimepicker2").on("dp.change", function (e) {
        $('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
    });
    

    相关文章

      网友评论

          本文标题:datapicker option日期区间

          本文链接:https://www.haomeiwen.com/subject/vsekkqtx.html