Javascript Magento日历:日期选择器问题以禁用今天之前的天

Javascript Magento日历:日期选择器问题以禁用今天之前的天,javascript,magento,datepicker,prototype,Javascript,Magento,Datepicker,Prototype,我在前端定制Magento日历时遇到问题: 我想禁用今天之前的日期,这已经起作用了,但我无法选择实际月份的日期 但是,如果我单击下个月的任何日期并返回到本月,那么我可以选择日期 这是我的密码: function disabledDate(date) { var today = new Date(); if(date <= today){ return true; } else { return false; } }; Cale

我在前端定制Magento日历时遇到问题: 我想禁用今天之前的日期,这已经起作用了,但我无法选择实际月份的日期

但是,如果我单击下个月的任何日期并返回到本月,那么我可以选择日期

这是我的密码:

function disabledDate(date) {
    var today = new Date();
    if(date <= today){
        return true;
    } else {
        return false;
    }
};
Calendar.setup({
    inputField : 'date',
    ifFormat : '%e/%m/%Y',
    button : 'date_from_trig',
    align : 'Bl',
    singleClick : true,
    dateStatusFunc : disabledDate 
}); 

谢谢你的帮助

问题是这样解决的:

        function disabledDate(date) {
            var today = new Date();
            var dd = today.getDate();
            return date.getDate() < dd ;                    

        };

希望它能帮助某人:

像这样解决问题:

        function disabledDate(date) {
            var today = new Date();
            var dd = today.getDate();
            return date.getDate() < dd ;                    

        };

希望它能帮助某人:

您可以禁用上一天以及下一个月或本月的任何一天

在disableFunc中 0表示星期日禁用 1星期一 2星期二等

下面是代码

function dateRange(date) {
                        var now = new Date();
                        return (date.getTime() <= now.getTime() )
                      }

                     Calendar.setup({
                          inputField  : "aw_sarp_subscription_start",
                          ifFormat    : "%m/%e/%Y",
                          dateStatusFunc : dateRange,
                          button      : "aw_sarp_subscription_start_trig",
                          align       : "Bl",
                          disableFunc : function(date){
                                return date.getDay() === 0;
                              },
                          singleClick : true
                    });

您可以禁用上一天以及下一个月或本月的任何一天

在disableFunc中 0表示星期日禁用 1星期一 2星期二等

下面是代码

function dateRange(date) {
                        var now = new Date();
                        return (date.getTime() <= now.getTime() )
                      }

                     Calendar.setup({
                          inputField  : "aw_sarp_subscription_start",
                          ifFormat    : "%m/%e/%Y",
                          dateStatusFunc : dateRange,
                          button      : "aw_sarp_subscription_start_trig",
                          align       : "Bl",
                          disableFunc : function(date){
                                return date.getDay() === 0;
                              },
                          singleClick : true
                    });

要从日历中禁用上一天和下一天,例如:要禁用所有上一天和下一个周末

<input type="text" class="datepicker" id="datepicker" name="shipment_date" />
<img id="_datepicker" src="<?php echo $this->getSkinUrl('images/img.gif');?>" alt="calendar" width="20" height="24" border="0">

//<![CDATA[

function disabledDate(date){
    var now= new Date();
    if(date.getFullYear()   <   now.getFullYear())  { return true; }
    if(date.getFullYear()   ==  now.getFullYear())  { if(date.getMonth()    <   now.getMonth()) { return true; } }
    if(date.getMonth()      ==  now.getMonth())     { if(date.getDate()     <   now.getDate())  { return true; } }
    if (date.getDay() == 0 || date.getDay() == 6) {
            return true;
        } else {
            return false;
        }
};

Calendar.setup({
    cont: "datepicker",
    inputField : 'datepicker',
    button : '_datepicker',
    dateStatusFunc : disabledDate ,
});
//]]>

要从日历中禁用上一天和下一天,例如:要禁用所有上一天和下一个周末

<input type="text" class="datepicker" id="datepicker" name="shipment_date" />
<img id="_datepicker" src="<?php echo $this->getSkinUrl('images/img.gif');?>" alt="calendar" width="20" height="24" border="0">

//<![CDATA[

function disabledDate(date){
    var now= new Date();
    if(date.getFullYear()   <   now.getFullYear())  { return true; }
    if(date.getFullYear()   ==  now.getFullYear())  { if(date.getMonth()    <   now.getMonth()) { return true; } }
    if(date.getMonth()      ==  now.getMonth())     { if(date.getDate()     <   now.getDate())  { return true; } }
    if (date.getDay() == 0 || date.getDay() == 6) {
            return true;
        } else {
            return false;
        }
};

Calendar.setup({
    cont: "datepicker",
    inputField : 'datepicker',
    button : '_datepicker',
    dateStatusFunc : disabledDate ,
});
//]]>

我希望这个脚本能对某人有所帮助:

<script type="text/javascript">
    Calendar.setup({
        inputField: 'your_input_field',
        ifFormat: '<?php echo $this->getDateTimeFormat();?>',
        button: 'you_button',
        showsTime: true,
        align: 'Bl',
        singleClick: true,
        disableFunc: function(date) {
        //disables all dates before current date 
            var now = new Date();
            if(date.getFullYear() < now.getFullYear()){
                return true;
            }
            if(date.getFullYear() == now.getFullYear() && date.getMonth() < now.getMonth()){
                return true;
            }
            if(date.getMonth() == now.getMonth() && date.getDate() < now.getDate()){
                return true;
            }
        }
    });
</script>

我希望这个脚本能对某人有所帮助:

<script type="text/javascript">
    Calendar.setup({
        inputField: 'your_input_field',
        ifFormat: '<?php echo $this->getDateTimeFormat();?>',
        button: 'you_button',
        showsTime: true,
        align: 'Bl',
        singleClick: true,
        disableFunc: function(date) {
        //disables all dates before current date 
            var now = new Date();
            if(date.getFullYear() < now.getFullYear()){
                return true;
            }
            if(date.getFullYear() == now.getFullYear() && date.getMonth() < now.getMonth()){
                return true;
            }
            if(date.getMonth() == now.getMonth() && date.getDate() < now.getDate()){
                return true;
            }
        }
    });
</script>