在Joomla日历中禁用日期范围

时间:2022-08-25 19:26:03

I want to disable a date range in joomla calendar. Only the remaining days can be select. I have no idea how to do it. Plz help.

我想在joomla日历中禁用日期范围。只能选择剩余的天数。我不知道该怎么做。 Plz的帮助。

e.g. If I say 2012-2-20 to 2012-3-20 then only days in this range can be select all other has to be disable(or can not select).

例如如果我说2012-2-20到2012-3-20那么只有这个范围内的天可以选择所有其他必须禁用(或不能选择)。

Joomla Calendar Doc http://docs.joomla.org/API16:JHtml/calendar

Joomla Calendar Doc http://docs.joomla.org/API16:JHtml/calendar

5 个解决方案

#1


1  

Set minDate and maxDate for your date limit, i.e.

将minDate和maxDate设置为您的日期限制,即

$("#start_date").datepicker({
    dateFormat:'yy-mm-dd',
    showOn: 'button',
    buttonImageOnly: true,
    minDate: newmindate ,
    maxDate: newmaxdate 
});

Set variable newmindate and newmaxdate.

设置变量newmindate和newmaxdate。

#2


0  

What I would do is add a little snippet of code in Javascript where any time you have an event on blur on that input you retrieve the value, check if it is > 2012-2-10 && < 2012-3-10, and if not clear the value of that input.

我要做的是在Javascript中添加一小段代码,任何时候你在该输入上有模糊事件时检索值,检查它是否> 2012-2-10 && <2012-3-10,如果不清楚那个输入的价值。

#3


0  

I ran into a similar problem with several Joomla sites that I administer. I was already using jQuery, so I decided to go with JQuery UI Datepicker which has an easy-to-use min/max date feature. If you're already using these libraries, or if you're willing to 1) add them and 2) potentially mess up your design unity, I would recommend it.

我遇到了几个我管理的Joomla网站的类似问题。我已经在使用jQuery了,所以我决定使用JQuery UI Datepicker,它具有易于使用的最小/最大日期功能。如果您已经在使用这些库,或者您愿意1)添加它们并且2)可能会破坏您的设计统一性,我会推荐它。

#4


0  

<div>
    <input name="StartDate" id="StartDate" type="text" readOnly="readonly" data-val-required="The From field is required." data-val="true" jQuery15106987620498322786="53"/>
    <input name="EndDate" id="EndDate" type="text" readOnly="readonly" data-val-required="The To field is required." data-val="true" jQuery15106987620498322786="54"/>
</div>

$(function () {
    var dates = $("#StartDate, #EndDate").datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        minDate:0,
        dateFormat: 'dd/mm/yy',
        onSelect: function (selectedDate) {
            var option = this.id == "StartDate" ? "minDate" : "maxDate",
                    instance = $(this).data("datepicker"),
                    date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                        $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }

    });
});

#5


0  

3 years after your question and the calendar field in Joomla still can't do this. However, you can set a minimum year and a maximum year (but not a minimum month and a maximum month) by just editing the file media/system/js/calendar.js and changing the values of this.minYear and this.maxYear to the values of your choice.

你问题3年后,Joomla的日历领域仍然无法做到这一点。但是,您可以通过编辑文件media / system / js / calendar.js并将this.minYear和this.maxYear的值更改为to来设置最小年份和最大年份(但不是最小月份和最长月份)你选择的价值观。

#1


1  

Set minDate and maxDate for your date limit, i.e.

将minDate和maxDate设置为您的日期限制,即

$("#start_date").datepicker({
    dateFormat:'yy-mm-dd',
    showOn: 'button',
    buttonImageOnly: true,
    minDate: newmindate ,
    maxDate: newmaxdate 
});

Set variable newmindate and newmaxdate.

设置变量newmindate和newmaxdate。

#2


0  

What I would do is add a little snippet of code in Javascript where any time you have an event on blur on that input you retrieve the value, check if it is > 2012-2-10 && < 2012-3-10, and if not clear the value of that input.

我要做的是在Javascript中添加一小段代码,任何时候你在该输入上有模糊事件时检索值,检查它是否> 2012-2-10 && <2012-3-10,如果不清楚那个输入的价值。

#3


0  

I ran into a similar problem with several Joomla sites that I administer. I was already using jQuery, so I decided to go with JQuery UI Datepicker which has an easy-to-use min/max date feature. If you're already using these libraries, or if you're willing to 1) add them and 2) potentially mess up your design unity, I would recommend it.

我遇到了几个我管理的Joomla网站的类似问题。我已经在使用jQuery了,所以我决定使用JQuery UI Datepicker,它具有易于使用的最小/最大日期功能。如果您已经在使用这些库,或者您愿意1)添加它们并且2)可能会破坏您的设计统一性,我会推荐它。

#4


0  

<div>
    <input name="StartDate" id="StartDate" type="text" readOnly="readonly" data-val-required="The From field is required." data-val="true" jQuery15106987620498322786="53"/>
    <input name="EndDate" id="EndDate" type="text" readOnly="readonly" data-val-required="The To field is required." data-val="true" jQuery15106987620498322786="54"/>
</div>

$(function () {
    var dates = $("#StartDate, #EndDate").datepicker({
        defaultDate: "+1w",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        minDate:0,
        dateFormat: 'dd/mm/yy',
        onSelect: function (selectedDate) {
            var option = this.id == "StartDate" ? "minDate" : "maxDate",
                    instance = $(this).data("datepicker"),
                    date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                        $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }

    });
});

#5


0  

3 years after your question and the calendar field in Joomla still can't do this. However, you can set a minimum year and a maximum year (but not a minimum month and a maximum month) by just editing the file media/system/js/calendar.js and changing the values of this.minYear and this.maxYear to the values of your choice.

你问题3年后,Joomla的日历领域仍然无法做到这一点。但是,您可以通过编辑文件media / system / js / calendar.js并将this.minYear和this.maxYear的值更改为to来设置最小年份和最大年份(但不是最小月份和最长月份)你选择的价值观。