从JQuery datepicker禁用周末和前几天 $(函数(){ $.datepicker.setDefaults({dateFormat:'yy-mm-dd'}); $(“#datepicker1”).datepicker({beforeShowDay:$.datepicker.noWeekends}); $(“#datepicker1”).datepicker({minDate:0}); $(“#datepicker1”).datepicker(); });

从JQuery datepicker禁用周末和前几天 $(函数(){ $.datepicker.setDefaults({dateFormat:'yy-mm-dd'}); $(“#datepicker1”).datepicker({beforeShowDay:$.datepicker.noWeekends}); $(“#datepicker1”).datepicker({minDate:0}); $(“#datepicker1”).datepicker(); });,jquery,html,Jquery,Html,我有上面的代码,我想从JQuery datepicker中禁用周末和以前的日期。。但它所做的是,它只禁用周末,而不是过去的几天。我哪里出错了???你可以这样试试 <script> $(function() { $.datepicker.setDefaults({dateFormat: 'yy-mm-dd'}); $("#datepicker1").datepicker({ beforeShowDay: $.datepicker.noWeeken

我有上面的代码,我想从JQuery datepicker中禁用周末和以前的日期。。但它所做的是,它只禁用周末,而不是过去的几天。我哪里出错了???

你可以这样试试

<script>
    $(function() {
        $.datepicker.setDefaults({dateFormat: 'yy-mm-dd'});
        $("#datepicker1").datepicker({ beforeShowDay: $.datepicker.noWeekends });
        $( "#datepicker1" ).datepicker({ minDate: 0});
        $( "#datepicker1" ).datepicker();                   
    });
</script>
文件

  • 你可以这样试试

    <script>
        $(function() {
            $.datepicker.setDefaults({dateFormat: 'yy-mm-dd'});
            $("#datepicker1").datepicker({ beforeShowDay: $.datepicker.noWeekends });
            $( "#datepicker1" ).datepicker({ minDate: 0});
            $( "#datepicker1" ).datepicker();                   
        });
    </script>
    
    文件

  • 你可以这样试试

    <script>
        $(function() {
            $.datepicker.setDefaults({dateFormat: 'yy-mm-dd'});
            $("#datepicker1").datepicker({ beforeShowDay: $.datepicker.noWeekends });
            $( "#datepicker1" ).datepicker({ minDate: 0});
            $( "#datepicker1" ).datepicker();                   
        });
    </script>
    
    文件

  • 你可以这样试试

    <script>
        $(function() {
            $.datepicker.setDefaults({dateFormat: 'yy-mm-dd'});
            $("#datepicker1").datepicker({ beforeShowDay: $.datepicker.noWeekends });
            $( "#datepicker1" ).datepicker({ minDate: 0});
            $( "#datepicker1" ).datepicker();                   
        });
    </script>
    
    文件


  • 将所有设置传递给一次呼叫

    $(function() {
        var date = new Date();
        var currentMonth = date.getMonth();
        var currentDate = date.getDate();
        var currentYear = date.getFullYear();
       $('#txtDate').datepicker({ 
           minDate: new Date(currentYear, currentMonth, currentDate),  // will disable past days
           beforeShowDay: $.datepicker.noWeekends // Will disable weekends
       });
    });
    

    将所有设置传递给单个呼叫

    $(function() {
        var date = new Date();
        var currentMonth = date.getMonth();
        var currentDate = date.getDate();
        var currentYear = date.getFullYear();
       $('#txtDate').datepicker({ 
           minDate: new Date(currentYear, currentMonth, currentDate),  // will disable past days
           beforeShowDay: $.datepicker.noWeekends // Will disable weekends
       });
    });
    

    将所有设置传递给单个呼叫

    $(function() {
        var date = new Date();
        var currentMonth = date.getMonth();
        var currentDate = date.getDate();
        var currentYear = date.getFullYear();
       $('#txtDate').datepicker({ 
           minDate: new Date(currentYear, currentMonth, currentDate),  // will disable past days
           beforeShowDay: $.datepicker.noWeekends // Will disable weekends
       });
    });
    

    将所有设置传递给单个呼叫

    $(function() {
        var date = new Date();
        var currentMonth = date.getMonth();
        var currentDate = date.getDate();
        var currentYear = date.getFullYear();
       $('#txtDate').datepicker({ 
           minDate: new Date(currentYear, currentMonth, currentDate),  // will disable past days
           beforeShowDay: $.datepicker.noWeekends // Will disable weekends
       });
    });
    

    小提琴:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    

    您可以一次性使用所有选项,而不是单独使用。 您多次调用datepicker,这是不需要的

    $(function () {
        $.datepicker.setDefaults({
            dateFormat: 'yy-mm-dd'
        });
        $("#datepicker1").datepicker({
            beforeShowDay: $.datepicker.noWeekends,
            minDate: 0
        });
    });
    

    小提琴:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    

    您可以一次性使用所有选项,而不是单独使用。 您多次调用datepicker,这是不需要的

    $(function () {
        $.datepicker.setDefaults({
            dateFormat: 'yy-mm-dd'
        });
        $("#datepicker1").datepicker({
            beforeShowDay: $.datepicker.noWeekends,
            minDate: 0
        });
    });
    

    小提琴:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    

    您可以一次性使用所有选项,而不是单独使用。 您多次调用datepicker,这是不需要的

    $(function () {
        $.datepicker.setDefaults({
            dateFormat: 'yy-mm-dd'
        });
        $("#datepicker1").datepicker({
            beforeShowDay: $.datepicker.noWeekends,
            minDate: 0
        });
    });
    

    小提琴:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    

    您可以一次性使用所有选项,而不是单独使用。 您多次调用datepicker,这是不需要的

    $(function () {
        $.datepicker.setDefaults({
            dateFormat: 'yy-mm-dd'
        });
        $("#datepicker1").datepicker({
            beforeShowDay: $.datepicker.noWeekends,
            minDate: 0
        });
    });
    

    每次为日期选择器指定一个选项时,都要重新初始化该日期选择器,要同时满足这两个要求,请这样做

    JQUERY代码:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    
    现场演示:


    快乐编码:)

    每次为日期选择器指定一个选项时,您都在重新初始化该日期选择器,要同时满足这两个要求,请按此方式执行

    JQUERY代码:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    
    现场演示:


    快乐编码:)

    每次为日期选择器指定一个选项时,您都在重新初始化该日期选择器,要同时满足这两个要求,请按此方式执行

    JQUERY代码:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    
    现场演示:


    快乐编码:)

    每次为日期选择器指定一个选项时,您都在重新初始化该日期选择器,要同时满足这两个要求,请按此方式执行

    JQUERY代码:

    $(function() {
       $.datepicker.setDefaults({
       // here we can have all the common properties which we need for all the datepickers
           dateFormat: 'yy-mm-dd',
           duration:"slow"
       });
    
       $('#datepicker1').datepicker({ 
           minDate:0,
           dateFormat: 'yy-mm-dd', // this is for single datepicker.
           beforeShowDay: $.datepicker.noWeekends
       });
    });
    
    现场演示:


    快乐编码:)

    这已经得到了回答。如果你有不同的东西,你可以发布it@susheel:事实上,我更喜欢这个答案,而不是你(和其他所有人)的答案,因为他实际上解释了问题所在,而不是简单地指定解决方案。冷静点,伙计们,为什么你对每一件事都投反对票。我只是说这是类似的答案。甚至我也在短时间内作了解释。我没有否决你的答案,谢谢:):)快乐编码:)@susheel:我的名字是Dreamweiver,这只是一个状态引用:)这已经回答了。如果你有不同的东西,你可以发布it@susheel:事实上,我更喜欢这个答案,而不是你的答案(以及所有其他答案),因为他实际上解释了问题所在,而不是简单地指定解决方案。冷静点,伙计们,为什么你对每件事都投反对票。我只是说这是类似的答案。甚至我也在短时间内作了解释。我没有否决你的答案,谢谢:):)快乐编码:)@susheel:我的名字是Dreamweiver,这只是一个状态引用:)这已经回答了。如果你有不同的东西,你可以发布it@susheel:事实上,我更喜欢这个答案,而不是你的答案(以及所有其他答案),因为他实际上解释了问题所在,而不是简单地指定解决方案。冷静点,伙计们,为什么你对每件事都投反对票。我只是说这是类似的答案。甚至我也在短时间内作了解释。我没有否决你的答案,谢谢:):)快乐编码:)@susheel:我的名字是Dreamweiver,这只是一个状态引用:)这已经回答了。如果你有不同的东西,你可以发布it@susheel:事实上,我更喜欢这个答案,而不是你的答案(以及所有其他答案),因为他实际上解释了问题所在,而不是简单地指定解决方案。冷静点,伙计们,为什么你对每件事都投反对票。我只是说这是类似的答案。甚至我也在短时间内作了解释。我没有否决你的答案,谢谢:):)快乐编码:)@susheel:我的名字是Dreamweiver,这只是一个状态引用:)