View Full Version : Need help with my datepicker

02-13-2009, 04:14 PM
I need some help with my datepicker. I'm using the datepicker tool from this website:

I have two date fields setup with the datepicker and they work together to create a date range.
the code I'm using for this is right from the website and it work perfectly.

function customRange(input){
minDate: (input.id == 'cmn_enddate' ? $('#cmn_stdate').datepick('getDate') : null),
maxDate: (input.id == 'cmn_stdate' ? $('#cmn_enddate').datepick('getDate') : null)

// Add DatePicker
$('#cmn_stdate').datepick({beforeShow: customRange});
$('#cmn_enddate').datepick({beforeShow: customRange});

cmn_stdate is the start date and cmn_enddate is the end date. If a user picks the start date first, then the end date range cannot be selected before the start date. Likewise, if a user picks the end date first, a start date that comes after the end date cannot be chosen. As I said, this is working great.

However, I want it so that only dates that start two days from today to be selectable. All dates prior to that should be unselectable. This seems to only work if I use the minDate attribute by itself. But then the start/end ranges function doesn't work.

Any ideas would be most appreciated.


02-13-2009, 04:29 PM
for clarification, this is a jquery plugin

02-13-2009, 07:13 PM
Never mind. It's not perfect but when I simply replace the first null with +2 it works. Still cannot control the end date exactly the way I'd like but the issue is forced when the start date can only be selected as desired.