简体   繁体   English

从日期选择器禁用日期

[英]Disable date from datepicker

I'm trying to disable dates from my datepicker which is the past days and about 30 days after the current date but I think I'm missing something.我试图从我的日期选择器中禁用日期,即过去几天和当前日期后大约 30 天,但我想我错过了一些东西。 Here's a snippet of what I got.这是我得到的一个片段。

Here is the php code.这是php代码。

<h3 style="font-family:Lucida Sans; font-size:12px;color:#514C4C;">Reservation Date:</h3>
                <input type ="date" class="inputbox6" value ="<?php date_default_timezone_set('Asia/Manila');
                $date = date('M-d-Y');
                echo $date; ?> " id="datepicker" style ="border-top-left-radius:5px; border-bottom-right-radius:5px; border-top-right-radius:5px; border-bottom-left-radius:5px;" name ="res_date"/>
                <div style="margin-top:0px; margin-left:0px; margin-bottom:5px; width:220px; color:#F00; font-size:12px;">
                    <?php if (isset($_POST['btnReserve'])) { ?>
                        <?php if (empty($res_date)) { ?>
                                <?php echo "Please choose your reservation date."; ?>
                        <?php } ?>
                    <?php } ?>
                </div>

And Here is the script.这是脚本。

<script language = "javascript">
$('#datepicker').datepicker({ minDate:0});
$('#datepicker').datepicker({ maxDate:30});
</script>

You need to put it inside the document ready handler, and you need to put all the options in one call to datepicker :您需要将它放在文档就绪处理程序中,并且您需要将所有选项放在对datepicker一次调用中:

$(function() {
    $("#datepicker").datepicker( {
        minDate: 0,
        maxDate: 30
    });
});

FIDDLE小提琴

For disabling the current date from the calendar, you can change the input tag as below要从日历中禁用当前日期,您可以更改输入标签如下

<input type="date" class="inputbox6" min="<?php echo date('Y-m-d', strtotime("+1 days")); ?>" />

and to block one month date in the date picker change as follow,并在日期选择器更改中阻止一个月的日期,如下所示,

<input type="date" class="inputbox6" min="<?php echo date('Y-m-d', strtotime("+1 MONTH")); ?>" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM