Hello all,
i posted this a while ago and the thread closed, this was my original question:
<script type="text/javascript">
$(function() {
$('#inlineDatepicker').datepick({
rangeSelect: true,
monthsToShow: 3,
minDate: '+7d',
rangeSeparator: '|',
altField: '#resdate',
altFormat: 'dd-mm-yyyy',
pickerClass: 'locgrid',
onDate: nationalDays
}
);
});
var natDays = [[12, 18, 2010], [12, 19, 2010]];
function nationalDays(date, inMonth) {
if (inMonth) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() + 1 == natDays[i][0] &&
date.getDate() == natDays[i][1] &&
date.getFullYear() == natDays[i][2]
) {
return {dateClass: natDays[i][3] + '_day', selectable: false};
}
}
}
return {};
}
now what i'm trying to accomplish is, when a user clicks a start- and enddate and there is a natDays variable in between to throw an error message.
any ideas?
This is what airshow answered, thanks for that btw:
Piet,
I think I have it.
In the datepick settings, change onDate: nationalDays to onSelect: nationalDays .
Then nationalDays should be as follows:
function nationalDays(dates) {
var natDate;
var includesNatDate = false;
for (i=0; i<natDays.length; i++) {
d = $.datepick.newDate(natDays[i][2], natDays[i][0], natDays[i][1]);
if(d.getTime() >= dates[0].getTime() && d.getTime() <= dates[1].getTime()) {
includesNatDate = true;
break;
}
}
$("#message").html('includesNatDate : ' + includesNatDate);
}
In the last line, I just display a true|false message but you will do whatever is necessary in your application. There's no point returning true|false from nationalDays because it is a callBack function and you don't have access to the returned value.
Hope this helps.
Airshow
-----------
Somehow it is not working for me, it just does nothing, anyone else got a clue for me?
thanks a lot!