jQuery UI datetimepicker and ASP.NET CompareValidator for DataTypeCheck

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 }); });


I think I found a solution. This is a bug that occurs in IE, not Firefox (I didn't test any other browsers). The solution was to override the onSelect method in the initialization:

$("#<%= uxInstallDate.ClientID %>").datepicker({ changeMonth: true, onSelect: function() { } });

I found a description of the issue and the solution here and an alternate solution here.


Base on the solution of Jamie and the alternate solution he provides, here is my workaround to bypass this strange bug that only occurs with IE.

I presume that a date selected by the datepicker control is a valid date so I hide the message or image error of the CompareValidator if it is visible.

$(".myControl").datepicker({ onSelect: function() { if ($.browser.msie) { if ($(this).next("span").css("display") != "none") { $(this).next("span").css("display", "none"); } } else { $(this).trigger('change'); } } });

Hope that help


  • how to make folder name with yesterday's date?
  • Unsupported Operation. A document processed by the JRC engine cannot be opened in the C stack.
  • position: fixed with margin: auto in IE9/10
  • Colorize knockoutjs comment bindings in code editor
  • Azure Service Bus topics partitioning
  • Updating one element of a bound Observable collection
  • Launch powershell script from UWP app with FullTrustProcessLauncher class
  • Doctrine2 inverse persistance not working in nested forms
  • Use New-AzureDeployment to deploy cloud service, But error occurs “The HTTP version specified is not
  • Where can I get Microsoft.DirectX.dll?
  • matlab crashes without dump file when using fopen for file
  • C# Report Renderer for SRSS 2008 R2 - Missing Parameter
  • jquery validation - waiting for remote check to complete
  • Compress a file with GZipStream while maintaining its meta-data
  • C# List of Panels
  • powershell Get-Counter -ComputerName parameter on Windows 7
  • Xamarin MonoAndroid Azure mobile service InsertAsync
  • Detecting null parameter in preprocessor macro
  • How can I tell a form not to dispose a particular control when it closes?
  • WPF version of .ScaleControl?
  • uml Composition relationships to RDF and OWL
  • Private IP address in reserved subnet range
  • How To Customize ASP.NET Chart Databound To SqlDataSource
  • How to return DataSet (xsd) in WCF
  • Overlapping controls in Windows XP
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • IE7 and TinyMCE with Plone
  • Loading .coffee files via a view in Rails
  • Custom validator control occupying space even though display set to dynamic
  • NHibernate Validation Localization with S#arp Architecture
  • Bug in WPF DataGrid
  • TFS: Get latest causes slow project reloading
  • Javascript Callbacks with Object constructor
  • How to make Safari send if-modified-since header?
  • Traverse Array and Display in markup
  • json Serialization in asp
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal