I'm using an ASP.NET textbox with the jQuery UI datepicker. The textbox allows edits so that the user can enter a date manually or clear an existing entry. I added a CompareValidator to perform a data type check on the textbox and this causes an error after selecting a date with the datepicker. The error occurs in the ASP.NET client side validation:
Microsoft JScript runtime error: 'length' is null or not an object
the error occurs in ValidatorOnChange. How can I fix this? Is it possible to use datepicker with the ASP.NET validator controls?
My markup is:
<asp:Label runat="server" AssociatedControlID="uxInstallDate">Install Date</asp:Label>
<asp:TextBox ID="uxInstallDate" runat="server" Columns="10" />
<asp:CompareValidator runat="server" ControlToValidate="uxInstallDate" Operator="DataTypeCheck" Type="Date" Text="*" ErrorMessage="Install Date must be a date." Display="Dynamic" />
Note that the missing ID attribute in the CompareValidator is intentional and adding it doesn't make a difference. My jQuery initialization is:
$(document).ready(function() {
$("#<%= uxInstallDate.ClientID %>").datepicker({ changeMonth: true });
});