the reason i use beforeShow is because doing it your way sets it when the page loads, now my users will come in and pick a start date and they could change this an infinite amount of times and i need the end date to reflect that each time. I believe your way only initializes it once. Thanks for the reply regarding the maxDate, looks like i'll have to do it the hard way then. Maybe something to add to the next version of jquery :).
On Aug 20, 3:11 pm, Jörn Zaefferer <[email protected]> wrote: > The main problem here is that the datepicker doesn't, or only barely, > expose its date-parsing abilities. So for that to work, you have to > get the date, transform it into something where you can add two > months, transform it back into something the datepicker understands, > and set that as the maxDate. > > Or your usage of beforeShow is rubbish. Instead of returning something > which gets ignored by the datepicker, you actually need to set these > options: $(this).datepicker("option", { minDate: ..., maxDate: ... }); > > Jörn > > On Thu, Aug 20, 2009 at 1:43 PM, Jaggi<[email protected]> wrote: > > > I have two fields a start date and end date. What i've done is set the > > minDate of start date to today and then i set the minDate of end date > > to whatever startDate is set to. This all works fine. The issue is > > with setting maxDate of end date. I want to set it to 2months in the > > future of whatever the minDate is set to (so basically 2months ahead > > of the start date). Everything i've tried to do this has resulted in > > random results mostly in disabling any selecting of the date. > > > [code] > > $('#endDate').datepicker({ > > dateFormat: 'dd-mm-yy', > > beforeShow: function(){ > > return{ minDate: > > $('#startDate').datepicker('getDate'), > > maxDate: > > $('#startDate').datepicker('getDate') + '+2m'} > > } > > }).attr('readonly', 'readonly'); > > [/code] > > > this is an example of my code, the maxDate setting doesn't work but > > thought i'd just give an example. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
