I am having two text fields From, To.Here i want to do many things with is two fields.
- I want to select next three days on selected date.Which means,if I am selecting
jan 1,2012in From field , then To field should automatically selectjan 1,2,3 2012. - While I am hover on
jan 1, It should highlightjan 1,2,3 - While I am selecting on
jan 1it should it disable after 10 days (afterjan 10all dates should disabled) - Suppose I disabled
jan 2means.While I am selectingjan 1tool tip message should say you can’t select these dates.
Give me the reference idea which functions are used to do this.If you have example code for any of these please share.It will be very help full.
This is my setup
var dates = jQuery("#From,#To").datepicker({
beforeShowDay: excludeDates,
showButtonPanel: true,
dateFormat: "m/d/y",
altFormat: 'yy-mm-dd',
minDate: 0,
onSelect: function(selectedDate, inst) {
var option = this.id == "From" ? "minDate" : "maxDate",
instance = jQuery(this).data("datepicker"),
date = jQuery.datepicker.parseDate(instance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
var d = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay);
var mydate = jQuery.datepicker.formatDate('yy-mm-dd', d);
}
});
Thanks in advance
It’s not a complete answer but I’ve hacked something together which should hopefully get you started. It meets some of your requirements but the hover highlighting is not perfect (sometimes extra dates are left highlighted) and I’m not happy with all of the JavaScript Date objects so there is probably some optimisation to be done. The code is included below:
HTML
CSS
JavaScript
Note that the demo jsFiddle also includes a jQueryUI Theme and the Multiple Dates Picker plugin as advised by @diEcho