Closed GoogleCodeExporter closed 8 years ago
I have resolve the problem with the following code, but i think, it is possible
to get the same result with a more simply way:
<input type="text" size="18" name="arrivalDate" id="arrivalDate" value="Mon,
23.08.2010" class="moduli_campi_testo"/>
<input type="text" size="18" name="departureDate" id="departureDate"
value="Mon, 30.08.2010" class="moduli_campi_testo"/>
<script type="text/javascript">
jQuery('#arrivalDate,#departureDate').datepick({
onSelect: customRange,
showOtherMonths: true, firstDay: 1, monthsToShow: 4,
minDate: +1,
dateFormat: 'D, dd.mm.yyyy',
regional: 'en'
});
jQuery('#arrivalDate').mouseover(function() {
if (this.value == 'Mon, 23.08.2010' && document.getElementById('departureDate').value == 'Mon, 30.08.2010'){
this.value = '';
jQuery('#departureDate').val('');
}
});
function formatNum(num){
var mynum = num * 1;
var retVal = mynum<10?'0':'';
return (retVal + mynum)
}
// this function sets the departurdate to 7 days more as the arrivalDate
function customRange(dates) {
if (this.id == 'arrivalDate') {
$('#departureDate').datepick('option', 'minDate', dates[0] || null);
var weekday = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var arrivalDate = document.getElementById('arrivalDate').value;
var d = $.datepick.parseDate('dd.mm.yyyy', arrivalDate.substr((arrivalDate.length-10),2)+'.'+arrivalDate.substr((arrivalDate.length-7),2)+'.'+arrivalDate.substr((arrivalDate.length-4),4));
d.setDate(d.getDate() + 7); // Add ?? days
document.getElementById('departureDate').value = weekday[d.getDay()] +", "+ formatNum(d.getDate()) +"."+ formatNum((d.getMonth()+1)) +"."+ d.getFullYear();
}
else {
$('#arrivalDate').datepick('option', 'maxDate', dates[0] || null);
}
}
//check if the dates are selected
document.getElementById('bookingForm').onsubmit = function(){
var returnval = false;
if(document.getElementById('arrivalDate').value == '' || document.getElementById('departureDate').value == '' || document.getElementById('arrivalDate').value == ''){
alert('Select arrival day !');document.getElementById('arrivalDate').value = ''; document.getElementById('departureDate').value = '';
this.arrivalDate.focus();
return false;
}
return true;
}
</script>
Original comment by egon.pescollderungg@gmail.com
on 22 Aug 2010 at 10:28
http://code.google.com/p/jquery-datepicker/wiki/NotTheUIDatePicker
Original comment by kelvin.l...@gmail.com
on 22 Aug 2010 at 2:38
Original issue reported on code.google.com by
egon.pescollderungg@gmail.com
on 21 Aug 2010 at 7:49