$(function () {
   $('#dateFrom').datepicker({
       onSelect:function(theDate) {
         $('#dateTo').datepicker('option', 'minDate', new Date
(theDate));
       }
   });

   $('#dateTo').datepicker({
     onSelect:function(theDate) {
       $('#dateFrom').datepicker('option', 'maxDate', new Date
(theDate));
     }
   });
});

On Aug 15, 2:39 pm, spill50 <rich...@visual-style.co.uk> wrote:
> Hi all,
>
> I have 2 datepickers a "from date" and a "to date". The selected "from
> date" sets the minDate of the "to date" and the "to date" sets the
> maxDate of "from date".
>
> I'm having difficulty getting the date picker to use both theonselect
> event and setting the initial date format of the first selected date.
>
> For example if i select the "from date" first it puts it in the text
> field in mm/dd/yy format then I select the "to date" which inserts in
> the format dd/mm/yy which subsequently messes up the min/max dates.
>
> It doesnt matter which I select first its always in the format mm/dd/
> yy and all others selections are in dd/mm/yy format.
>
> Here's my code any help would be great as I'm starting to pull my hair
> out lol.
>
>         $(document).ready(function() {
>
>                 $("#dateFrom").datepicker({
>                        onSelect:function(theDate) {
>                                 $("#dateTo").datepicker('option',{dateFormat: 
> 'dd/mm/yy', minDate:
> new Date(theDate)})
>
>                         }
>                 })
>
>                 $("#dateTo").datepicker({
>                        onSelect:function(theDate) {
>                                 
> $("#dateFrom").datepicker('option',{dateFormat: 'dd/mm/yy',
> maxDate: new Date(theDate)})
>
>                         }
>                 })
>
>         })

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to jquery-ui@googlegroups.com
To unsubscribe from this group, send email to 
jquery-ui+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to