Re[2]: Not selectable dates
2008/05/05 19:27
Viewed 4272 times
Replies: 0/0

Hello,

I have a form with two inputfields for a period. The First one is the from an the secend one is a to date. If the from date is chosen via the calendar I want the to calendar to disable every date < the from date.

My code for this looks like this:

                    <div id="content_input_epoch_start_lable" class="text">Von:</div>
<div id="content_input_epoch_start_input">
<input type="text" style="width:70px;height:13px;" name="f_date" class="solid" id="f_date" readonly="true" />&nbsp;
<img id="f_trigger" style="vertical-align: -35%" src="http://travelload.de/partner/my-travelload.de/messagecenter/gfx/cal.gif">
</div>
<div id="content_input_epoch_stop_lable" class="text">bis:</div>
<div id="content_input_epoch_stop_input">
<input type="text" style="width:70px;height:13px;" name="t_date" class="solid" id="t_date" readonly="true" />&nbsp;
<img id="t_trigger" style="vertical-align: -35%" src="http://travelload.de/partner/my-travelload.de/messagecenter/gfx/cal.gif">
</div>
<script type="text/javascript">


Calendar.setup({
inputField : "f_date", // id of the input field
ifFormat : "%d.%m.%Y", // format of the input field
showsTime : false, // will not display a time selector
button : "f_trigger", // trigger for the calendar (button ID)
singleClick : true, // single-click mode
step : 1 // show all years in drop-down boxes (instead of every other year as default)
});
Calendar.setup({
inputField : "t_date", // id of the input field
ifFormat : "%d.%m.%Y", // format of the input field
showsTime : false, // will not display a time selector
button : "t_trigger", // trigger for the calendar (button ID)
singleClick : true, // single-click mode
step : 1, // show all years in drop-down boxes (instead of every other year as default)
dateStatusFunc : dateStatus
});

function dateStatus(date) {
var minDateString = document.getElementById("f_date").value;
var dateParts = minDateString.split(".");
var min = new Date(dateParts[2], dateParts[1] -1, dateParts[0]);
if (date.getTime() < min.getTime())
return true; // true says "disable"
else
return false; // leave other dates enabled
}
</script>

The disabling works fine, but if a from date is chosen the to calendar will not close after I clicked a date an does not fill a date to the Inputfield, unless I change the month or year (when I step back afterwards it works also fine).

Thx for help

Google