I am trying to create a date range using jQuery UI datepicker using two text fields. The first text field "start_date" will set the start date, and the second text field "end_date" will set the end date.
The code I have so far is as follows:
$('#start_date').live(
'focus',
function()
{
$('#end_date').datepicker(
{
dateFormat: 'dd MM yy',
minDate: new Date(),
maxDate: new Date(2012, 9, 15),
stepMonths: 2,
numberOfMonths: 2
}
);
$(this).datepicker(
{
dateFormat: 'dd MM yy',
minDate: new Date(),
maxDate: new Date(2012, 9, 15),
stepMonths: 2,
numberOfMonths: 2,
onSelect: function(dateText, inst)
{
var instance = $( this ).data("datepicker");
var date = $.datepicker.parseDate(instance.settings.dateFormat, dateText, instance.settings);
$('#end_date').datepicker('option', 'minDate', dateText);
}
}
);
}
);
NOTE . I use the live and focus event because all the contents of my page are loaded by an AJAX call. This may be right or wrong, but that is not what I would like to ask here;)
The above code is correct for me and works fine, but I like to set the value of the 'end_date' element to the selected one day +3.
, "start_date", "end_date" , "start_date", , . "End_date" +3 "start_date" .
?