Jquery datepicker popup not closing on select date in IE8 Jquery datepicker popup not closing on select date in IE8 asp.net asp.net

Jquery datepicker popup not closing on select date in IE8


As a date is selected, the datepicker triggers the change event on the INPUT element, but the ASP.Net validator picks up the click event instead, with the source an A element, and tries to find the validators on that A element, instead of the INPUT. This can be observed by inspecting event.srcElement inside the validator's ValidatorOnChange function. In browsers other than IE, event.type is 'change' and event.target is correctly the INPUT.

While the no-op function onSelect: function() { } prevents the error, by overriding the .change() built-in to the datepicker's default onSelect, it also prevents the validators from triggering. Here's a work-around for both:

onSelect: function() {  this.fireEvent && this.fireEvent('onchange') || $(this).change();}

This uses the normal .change() trigger except on IE, where it's required to use .fireEvent to get the event object to be associated with the change and not the click.


It seems to be a bug of sorts, but adding this line in the datepicker declaration should solve it:

onSelect: function() {}


The solutions provided above only prevents the error from occurring.

On the datepicker:

onSelect : function(dateText, inst){ inst.input.trigger('cValidate')

and bind the event to the calendar input element.

.bind('cValidate', function (event) { window.ValidatorOnChange(event); });

this will fire the validatorchanged event with the correct event args (input field).