title: How can i turn off ASP.NET required field validator "lost focus" behaviour
body: <p>I have some code where I need two separate required field validators for one control, both in separate validation groups which are then validated by two separate buttons.</p>
  
  <p>This approach works well when the buttons are clicked but both validators show if I enter a value in the textbox and then remove it.</p>
  
  <p>Is there a way to turn this"lost focus" validation off? I only need it to validate when the buttons are clicked. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Unfortunately, if I set EnableClientScript=false then I dont have <em>any</em> client notifications. What I want is for the dynamic error message to show (effectivly in the OnClientClick event of the button) but not the "lost focus" of the textbox.</p>
  
  <p>Is there some way I can disable or "unhook" the lostfocus client event?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>A combination dDejan's answer and womp's answeer <a href="https://stackoverflow.com/questions/2158052/enable-disable-asp-net-validator-controls-within-a-specific-validationgroup-wit">here</a> sorted the problem perfectly. </p>
  
  <p>My final code looks like this (for anyone else with a similar situation)...</p>
  
  <p>Javascript...</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(document).ready(function() {
          $('body').fadeIn(500);
  
          //Turn off all validation = its switched on dynamically
          $.each(Page_Validators, function(index, validator) {
                  ValidatorEnable(validator, false);
          });
      });
  
      function ToggleValidators(GroupName) {
  
          $.each(Page_Validators, function(index, validator) {
              if (validator.validationGroup == GroupName) {
  
                  ValidatorEnable(validator, true);
  
              } else {
                  ValidatorEnable(validator, false);
              }
          });
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>ASPX Control Example...</p>
  
  <pre><code>&lt;telerik:RadTextBox Width="196px" ID="txtFirstName" runat="server" MaxLength="50" Skin="Black"&gt;&lt;/telerik:RadTextBox&gt;
  &lt;asp:RequiredFieldValidator ID="valFirstName" CssClass="Validator" runat="server" EnableClientScript="true" Display="Dynamic" ErrorMessage="You  must enter your first name." ControlToValidate="txtFirstName" ValidationGroup="NeededForEmail"&gt;&lt;/asp:RequiredFieldValidator&gt;
  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" CssClass="Validator" runat="server" EnableClientScript="true" Display="Dynamic" ErrorMessage="You  must enter your first name." ControlToValidate="txtFirstName" ValidationGroup="NeededForSubmit"&gt;&lt;/asp:RequiredFieldValidator&gt;
  </code></pre>
  
  <p>ASPX Button Code...</p>
  
  <pre><code>&lt;asp:Button ID="btnGetConfCode" runat="server" Text="Get Confirmation Code" OnClientClick="ToggleValidators('NeededForEmail')" OnClick="btnGetConfCode_Click" Width="100%" ValidationGroup="NeededForEmail"/&gt;
  
  &lt;asp:Button ID="btnRegisterUser" runat="server" Text="Register" OnClientClick="ToggleValidators('NeededForSubmit')" OnClick="btnRegisterUser_Click" Width="100px" ValidationGroup="NeededForSubmit" /&gt;
  </code></pre>
  
  <p>So, now there is no validation until a user clicks either the "Get Email Confirmation Code" button or the "Register" button. </p>
  
  <p>If they click the "Get Email Confirmation Code" button all of the controls validate apart from the textbox where the user is to input the email validation code and we only see one validator message.</p>
  
  <p>If they click the "Register" Button then all of the controls validate and we only see one validation message.</p>
  
  <p>If either button is pressed, the user goes back, adds and then removes some text then we only see one validator. Before this change you used to see both messages saying the same thing.</p>
  
  <p>Thank you for help guys</p>