Since adding an OnSelect to my Datepicker, the TextChanged event no longer fires for this control. My code is as follows:
$(function() {
$("#<%=txtStartDate.ClientID %>").datepicker({
minDate: 0,
dateFormat: 'dd-M-yy',
onSelect: function(dateText, inst) {
var theDate = new Date(Date.parse($(this).datepicker('getDate')));
$("#<%=txtEndDate.ClientID %>").datepicker('option', 'minDate', theDate);
}
});
$("#<%=txtEndDate.ClientID %>").datepicker({
dateFormat: 'dd-M-yy'
});
});
<%-- etc ---- %>
<asp:TextBox ID="txtStartDate" runat="server" AutoPostBack="true" OnTextChanged="txtStartDate_TextChanged"></asp:TextBox>
My other datepicker (txtEndDate) TextChanged event does fire so can only put it down to the OnSelect being defined for the txtStartDate control.
Greatly appreciate any help on this one. Cheers!
After a short check of the jQuery UI Datepicker sources the solution is to just fire the change event yourself
The reason for this are the following lines in the jQuery UI Datepicker source
As you can see jQuery UI Datepicker fire the
changeevent per default if the datepicker instance is aninputfield but doesn't fire it if you specified a customonSelecthandler (as you did).You could argue that actually this is the correct behavior as it guarantees you maximal configurability. You can decide if you want the
changeevent to happen or not this way.But I agree that this behavior maybe should be documented.