title: Jquery datepicker popup not closing on select date in IE8
body: <p>I've got a web form with a start date field. I've tied a jquery datepicker to the txt field. Now when I choose a date in FF, the selected date is populated in the text box and the calendar popup closes. However when I do the same thing in IE8, the selected date is populated in the text box but the popup remains open. I've also noticed that a script error is generated as soon as I select a date in the popup calendar.</p>
  
  <p>I'm using jquery 1.3.2, jquery-ui 1.7.2, and .NET 3.5. Here's an example of my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function() {
      $("#&lt;%=txtStartDate.ClientID%&gt;").datepicker({
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        showOn: 'button',
        buttonImage: '/_layouts/images/CALENDAR.GIF',
        buttonImageOnly: true
      });
    });
  &lt;/script&gt;
  &lt;div id="stylized"&gt;
    &lt;asp:ValidationSummary ID="vs" runat="server" CssClass="messages-error" HeaderText=" Action required before the form can be submitted." ForeColor="" ValidationGroup="sh" /&gt;
    &lt;div class="formrow"&gt;
      &lt;div class="ms-formlabel formlabel"&gt;
        &lt;asp:Label ID="lblStartDate" runat="server" CssClass="ms-standardheader" AssociatedControlID="txtStartDate"&gt;Start Date:&lt;/asp:Label&gt;
      &lt;/div&gt;
      &lt;div class="ms-formbody formfield"&gt;
        &lt;asp:RequiredFieldValidator ID="reqStartDate" runat="server" ControlToValidate="txtStartDate" ErrorMessage="Start Date is a required field." Text="*" Display="Dynamic" ValidationGroup="sh"&gt;&lt;/asp:RequiredFieldValidator&gt;
        &lt;asp:CompareValidator ID="cvStartDate" runat="server" ControlToValidate="txtStartDate" ErrorMessage="Date must be in the format MM/DD/YYYY" Text="*" Display="Dynamic" ValidationGroup="sh" Operator="DataTypeCheck" Type="Date"&gt;&lt;/asp:CompareValidator&gt;
        &lt;asp:TextBox ID="txtStartDate" runat="server"&gt;&lt;/asp:TextBox&gt;
        &lt;span class="formMessage"&gt;ex. MM/DD/YYYY&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="buttonrow"&gt;
      &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="ms-ButtonHeightWidth" OnClick="Submit_Click" ValidationGroup="sh" /&gt;
      &lt;asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="ms-ButtonHeightWidth" OnClick="Cancel_Click" CausesValidation="false" /&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's the script error I get in IE when I select the date:</p>
  
  <p>'length' is null or not an object</p>
  
  <p>WebResource.axd</p>
  
  <p>Here's the code where the error is being thrown from:</p>
  
  <pre><code>function ValidatorOnChange(event) {
    if (!event) {
      event = window.event;
    }
    Page_InvalidControlToBeFocused = null;
    var targetedControl;
    if ((typeof(event.srcElement) != "undefined") &amp;&amp; (event.srcElement != null)) {
      targetedControl = event.srcElement;
    }
    else {
      targetedControl = event.target;
    }
    var vals;
    if (typeof(targetedControl.Validators) != "undefined") {
      vals = targetedControl.Validators;
    }
    else {
      if (targetedControl.tagName.toLowerCase() == "label") {
          targetedControl = document.getElementById(targetedControl.htmlFor);
          vals = targetedControl.Validators;
      }
    }
    var i;
    for (i = 0; i &lt; vals.length; i++) {
      ValidatorValidate(vals[i], null, event);
    }
    ValidatorUpdateIsValid();
  }
  </code></pre>
  
  <p>It happens on the .length in the for loop at the end. Vals is null and isn't found in the previous if/else. I've stepped through the javascript and if (typeof(targetedControl.Validators) != "undefined") returns false and then if (targetedControl.tagName.toLowerCase() == "label") returns false too. Thus the length is null or not an object error.</p>
  
  <p>Now I'm not sure if the datepicker popup not closing in IE and the script error in the WebResources.axd file are related errors, but I'm leaning that way. Can anyone tell me why the popup isn't closing?</p>