admin管理员组文章数量:1333688
I have a problem to customise the Magento calendar in frontend: I want to disable the days before today, that's already works, but I can't select dates in the actual month.
But, If I click any of the date in next month and returns to the present month, then I can select the dates!!!!!!
Here is my code:
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
});
Thanks for help.
I have a problem to customise the Magento calendar in frontend: I want to disable the days before today, that's already works, but I can't select dates in the actual month.
But, If I click any of the date in next month and returns to the present month, then I can select the dates!!!!!!
Here is my code:
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
});
Thanks for help.
Share Improve this question asked Mar 25, 2014 at 12:47 DaliDali 7,88228 gold badges114 silver badges178 bronze badges5 Answers
Reset to default 3Problem solved like this:
function disabledDate(date) {
var today = new Date();
var dd = today.getDate();
return date.getDate() < dd ;
};
Hope that it helps someone :)
disableFunc: function(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;
}
}
You can disable prevous days as well as any of the day in ing or current month.
In disableFunc 0 is for Sunday to disable 1 for Monday 2 for Tuesday and so on.
Following is the code.
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
});
To disable previous and uping days from calendar , EX : To disable all previous days and uping weekends ,
<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 ,
});
//]]>
I hope for someone this script will help:
<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>
本文标签: javascriptMagento calendar Datepicker issue to disable days before todayStack Overflow
版权声明:本文标题:javascript - Magento calendar: Datepicker issue to disable days before today - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742356610a2459540.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论