When we develop asp.net sites, we use the jquery UI datepicker with asp.net validation controls such as: RequiredFieldValidator:
Copy Code code 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>
Then when we select a date in the DatePicker, the error "' Length ' is empty or not an object" appears. This is due to the DatePicker bug, and after my research, I found a very simple workaround-capturing the DatePicker onselect event without any processing:
Copy Code code as follows:
$ ("#<%= txtdate.clientid%>"). DatePicker ({
Onselect:function (Datetext, inst) {
Don't do any processing
}
});
Now that we have chosen a date, we will not have an error "length ' is empty or not an object", and the ASP.net validation control will run as usual.