See the details here
var startid= 'jos_events___start_date_cal';
var endid = 'jos_events___end_date_cal';
var start = document.id(startid).get('value').split('-');
var end = document.id(endid).get('value').split('-');
if (start.length > 1) {
var startdate = new Date();
startdate.setFullYear(start[0]);
startdate.setMonth(start[1].toInt() - 1);
startdate.setDate(start[2]);
var enddate = new Date();
enddate.setFullYear(end[0]);
enddate.setMonth(end[1].toInt() - 1);
enddate.setDate(end[2]);
if (enddate < startdate) {
alert('woops your end date is earlier than your start date');
document.id(endid).value = [I];[/I]
}
}