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
-~----------~----~----~----~------~----~------~--~---