title: Update ValidationSummary list on control blurs?
body: <p>A <code>ValidationSummary</code> will show a list of errors on postback. As each field is fixed, it's validator is fired, and any validation text will disappear. I want to automatically update the <code>ValidationSummary</code> as well.</p>
  
  <p>The following works fine:</p>
  
  <pre><code>&lt;asp:TextBox ID="ForenameTextBox" onblur="ValidationSummaryOnSubmit()" runat="server" /&gt;
  </code></pre>
  
  <p>but this isn't ideal, as it means changing and maintaining this on all fields. (<code>ValidationSummaryOnSubmit</code> is a Microsoft function.) So I tried to do it dynamically:</p>
  
  <pre><code>addEvent(window, "load", UpdateValidationSummary);
  
  function addEvent(obj, evType, fn) {
      if (obj.addEventListener) {
          obj.addEventListener(evType, fn, true);
      } else {
          if (obj.attachEvent) {
              var r = obj.attachEvent("on" + evType, fn);
              return r;
          }
      }
  }
  
  function removeEvent(obj, evType, fn) {
      if (obj.removeEventListener) {
          obj.removeEventListener(evType, fn, true);
          return true;
      } else if (obj.detachEvent) {
          var r = obj.detachEvent("on" + evType, fn);
          return r;
      }
  }
  
  function UpdateValidationSummary() {
      if (typeof (Page_Validators) == "undefined") {
          return;
      }
      var i, val, ctrl;
      for (i = 0; i &lt; Page_Validators.length; i++) {
          val = Page_Validators[i];
          if (val.controltovalidate != null &amp;&amp; val.controltovalidate != "") {
              ctrl = document.getElementById(val.controltovalidate);
              if (ctrl != null &amp;&amp; typeof (ValidationSummaryOnSubmit) == "function") {
                  //add call to ValidationSummary on blur
                  addEvent(ctrl, "blur", ValidationSummaryOnSubmit);
              }
          }
      }
  }
  </code></pre>
  
  <p>This doesn't work though - the whole <code>ValidationSummary</code> disappears when one field is fixed, and the <code>ValidationSummaryOnSubmit</code> function seems to get called twice. If I use a simple assignment instead of the <code>addEvent</code> function it works, but I want to cater for fields that might already have something going on in the <code>onBlur</code> event.</p>
  
  <p>Basically I think I just need to add a call to the <code>ValidationSummaryOnSubmit</code> function to the "list" of <code>onBlur</code> handlers for each control. Why doesn't the code above seem to do this?</p>