When we develop an ASP. NET site, if we use the jQuery UI Datepicker and ASP. NET verification controls (such as RequiredFieldValidator) in combination:
Copy codeThe Code is as follows: <asp: TextBox ID = "txtDate" runat = "server"> </asp: TextBox>
<Asp: RequiredFieldValidator ID = "reqDate" runat = "server" ControlToValidate = "txtDate" ErrorMessage = "*"> </asp: RequiredFieldValidator>
<Script type = "text/javascript" >$ ("# <% = txtDate. ClientID %>"). datepicker ();
</Script>
When we select a date in Datepicker, the error "'length' is null or not an object" will occur. This is caused by the Datepicker bug. After my research, I found a very simple solution-capture the onSelect event of Datepicker without any processing:Copy codeThe Code is as follows: $ ("# <% = txtDate. ClientID %>"). datepicker ({
OnSelect: function (dateText, inst ){
// No Processing
}
});
Now, after a date is selected, the error "'length' is null or not an object" will not appear, and the ASP. NET verification control can also run as usual.