Question

I use IE 6 and 7. My project contains jQuery.js v.1.9.1 and jQuery UI v.1.9.2.

I have html page with jQuery calendar field:

...
<input type='text' id='Birthday'>
<!-- for only test purpose-->
<input type='button' style="width: 100px;" value="Get value" id='getValue'>
...

And javascipt file:

$(document).ready(function () {
     $('#Birthday').datepicker({showOn: "button"});
     $('#Birthday').datepicker("setDate", new Date(1930, 0, 1));
     $('#getValue').click(function(){
          alert($('#Birthday').datepicker("getDate"));
     });
});

Then I edit input textbox (without open Calendar dialog) and set date to 01/01/1958 and click on button "Get value". Alert box will show 01/01/1930 (wrong date). I try to use .datepicker("refresh") command after "setDate" but result is same.

How fix jQuery UI setDate function for working in IE 6...10 ?

Was it helpful?

Solution

I fixed this problem by adding the onSelect parameter to Datepicker:

$('#Birthday').datepicker({
   showOn: "button",
   onSelect: function()
   {
     // this will fire change on the underlying input
     $(this).change();
   }
});

This code works fine in IE 6/7/8/9.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top