When you are adding 1 to the date text, it is adding it as a string.
You need to operate on it as a date. This should work for you:
$("#arrive").datepicker({
minDate: new Date(2009, 11 - 1, 6),
onSelect: function(dateText, inst){
var dtArrive = $.datepicker.parseDate('mm/dd/yy', dateText);
var dtNextDay = $.datepicker.parseDate('mm/dd/yy', dateText);
dtNextDay.setDate(dtNextDay.getDate()+1);
var dtDepart = $("#depart").datepicker("getDate");
//only (re)set the depart date if it is not yet set or earlier
than allowed
if (dtDepart == null || dtDepart < dtNextDay){
$("#depart").datepicker("setDate", dtNextDay);
}
$("#depart").datepicker("option","minDate", dtNextDay);
}
});
$("#depart").datepicker({minDate: new Date(2009, 11 - 1, 7)});
It is here if you want to test it: http://jsbin.com/uteba/edit
Hth,
Dave
On Jul 28, 2:30 pm, Yvan <[email protected]> wrote:
> Thanks! Just one last question --
>
> If I was to choose November 6th from the "Arrive" datepicker, .. the
> first choosable date in the "Depart" datepicker
> should be dynamically set to November 7th
>
> How would I achieve that?
>
> - yg
>
> On Jul 28, 2:16 pm, James Curran <[email protected]> wrote:
>
> > $(document).ready(function() {
> > $("#arrive").datepicker({
> > minDate: new Date(2009, 11 - 1, 6),
> > onSelect: function(dateText, inst)
> > { $("#depart').datepicker("option",
> > "minDate", new Date(dateText)); }
> > });
> > $('#arrive').datepicker();
> > $('#calendar-trigger-arrive').click(function() {
> > $('#arrive').datepicker('show');
> > });
> > });
>
> > On Tue, Jul 28, 2009 at 2:09 PM, Yvan<[email protected]> wrote:
>
> > > I'm unsure about specifically where within my script I'd need to add
> > > the function you've provided. My script is as follows:
>
> > > <script type="text/javascript">
> > > $(document).ready(function() {
> > > // $('#arrive').datepicker({dateFormat: 'dd-M-yy'});
> > > $("#arrive").datepicker({minDate: new Date(2009, 11 - 1, 6),});
> > > $('#arrive').datepicker();
> > > $('#calendar-trigger-arrive').click(function() {
> > > $('#arrive').datepicker('show');
> > > });
> > > });
> > > </script>
>
> > > Please advise.
>
> > > Thanks,
> > > - yg
>
> > > On Jul 28, 1:56 pm, James Curran <[email protected]> wrote:
> > >> Well, this is untested, but it seems right......
>
> > >> $('#dateArrive').datepicker({onSelect: function(dateText, inst)
> > >> {
> > >> $("#dateDepart').datepicker("option", "minDate", new Date(dateText));
> > >> })
>
> > >> });
> > >> On Tue, Jul 28, 2009 at 1:35 PM, Yvan<[email protected]> wrote:
>
> > >> > I have 2 jquery-based datepickers on a site that I'm developing
> > >> > (lefthand column - quick reservation form)
>
> > >> >http://www.theseagatehotel.com/www.theseagatehotel.com/index.html
>
> > >> > Is there any way that I can update the datepickers so that when you
> > >> > choose an "Arrive" date, .... the first choosable "Depart" date would
> > >> > be automatically updated to be 1 day after the chosen "arrive" date?
>
> > >> > For example, .. if I was to choose November 6th from the "Arrive"
> > >> > datepicker, .. the first choosable date in the "Depart" datepicker
> > >> > should be dynamically set to November 7th, .. and all dates before
> > >> > November 7th in that "Depart" datepicker should be grayed out and un-
> > >> > clickable.
>
> > >> > How would I accomplish something like this? Is it even technically
> > >> > possible?
>
> > >> > Thanks,
> > >> > - Yvan
>
> > >> --
> > >> Truth,
> > >> James
>
> > --
> > Truth,
> > James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---