title: customvalidator for client side validation not working
body: <p>We have a form used by a number of our customers where someone can register on their web site.  It's customizable in that the owner of the form can set a field to be shown or hidden on the form and also required.  However, some fields if shown, require that another field be set for the form to be valid.  So the validation can be tricky.  The other tricky part is that we wanted all the error messages to show together in the validation summary.  If I simply had my own function that was called onclientclick for the linkbutton I couldn't add any error messages it generated to the validation summary.</p>
  
  <p>So the solution that we found originally was creating a custom validator on the page without setting it's controltovalidate property but leaving it's clientvalidationfunction set to the function we wanted to call.  This allowed us to set the errormessage of the sender argument so that it then showed up in the validationsummary.  </p>
  
  <p>We needed to add some additional validation logic and when doing this I realized that the page no longer works as it used to (I think it was working back in .net 2, now we're on .net 4).  </p>
  
  <p>Here's the basic html code I have.</p>
  
  <p>Web page - </p>
  
  <pre><code>&lt;asp:ValidationSummary ID="vsummary" runat="server" HeaderText="Oops, it appears the following required fields are not completed." CssClass="error" /&gt;
  &lt;asp:CustomValidator ID="cstCustomScripts" runat="server" ClientValidationFunction="ValidateExtraFields" /&gt;
  ...additional form fields here
  &lt;asp:LinkButton ID="btnAddUpdate" runat="server" onclick="SubmitProfile" /&gt;
  </code></pre>
  
  <p>And the javascript that gets called by the custom validator...</p>
  
  <pre><code>function ValidateExtraFields(sender, args) {
      args.IsValid = true;
  
      if (typeof window.RelocationSelectionRequired == 'function') {
          if (!RelocationSelectionRequired()){
              args.IsValid = false;
              sender.errormessage = "If you are open to relocating, please select the state(s) and cities.";
              return;
          }
      }
  
      if (typeof window.ValidateHomeState == 'function') {
          if (!ValidateHomeState()) {
              args.IsValid = false;
              sender.errormessage = "Home state is required.";
              return;
          }
      }
  
      if (typeof window.ValidateWorkState == 'function') {
          if (!ValidateWorkState()) {
              args.IsValid = false;
              sender.errormessage = "Work state is required.";
              return;
          }
      }
  
      var invalidNumberField = "";
      $("[data-validate-function='GreaterThanZero']").each(function () {
          var t = $(this);
          if (t.val().trim() == "0") {
              args.IsValid = false;
              invalidNumberField = t.attr("controlName");
              return false;
          }
      });
  
      if (invalidNumberField.length &gt; 0) {
          sender.errormessage = invalidNumberField + " cannot be zero.";
          return;
      }
  }
  </code></pre>
  
  <p>In the past the function would successfully append any messages from this function to the validationsummary control and not submit the form.  Now it still appends the message but the form also submits when it shouldn't.  Does anyone know if this is a result of moving from .net 2 to .net 4?  Or is there some other reason it no longer works?  Thanks.</p>