JQuery UI Datepicker length is null or is not an object error Solution

Source: Internet
Author: User
Tags jquery ui datepicker

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.