Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 871605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:39:51+00:00 2026-05-15T10:39:51+00:00

I have some code where I need two separate required field validators for one

  • 0

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.

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.

Is there a way to turn this”lost focus” validation off? I only need it to validate when the buttons are clicked.

EDIT

Unfortunately, if I set EnableClientScript=false then I dont have any 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.

Is there some way I can disable or “unhook” the lostfocus client event?

EDIT

A combination dDejan’s answer and womp’s answeer here sorted the problem perfectly.

My final code looks like this (for anyone else with a similar situation)…

Javascript…

<script type="text/javascript">

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

</script>

ASPX Control Example…

<telerik:RadTextBox Width="196px" ID="txtFirstName" runat="server" MaxLength="50" Skin="Black"></telerik:RadTextBox>
<asp:RequiredFieldValidator ID="valFirstName" CssClass="Validator" runat="server" EnableClientScript="true" Display="Dynamic" ErrorMessage="You  must enter your first name." ControlToValidate="txtFirstName" ValidationGroup="NeededForEmail"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" CssClass="Validator" runat="server" EnableClientScript="true" Display="Dynamic" ErrorMessage="You  must enter your first name." ControlToValidate="txtFirstName" ValidationGroup="NeededForSubmit"></asp:RequiredFieldValidator>

ASPX Button Code…

<asp:Button ID="btnGetConfCode" runat="server" Text="Get Confirmation Code" OnClientClick="ToggleValidators('NeededForEmail')" OnClick="btnGetConfCode_Click" Width="100%" ValidationGroup="NeededForEmail"/>

<asp:Button ID="btnRegisterUser" runat="server" Text="Register" OnClientClick="ToggleValidators('NeededForSubmit')" OnClick="btnRegisterUser_Click" Width="100px" ValidationGroup="NeededForSubmit" />

So, now there is no validation until a user clicks either the “Get Email Confirmation Code” button or the “Register” button.

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.

If they click the “Register” Button then all of the controls validate and we only see one validation message.

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.

Thank you for help guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:39:52+00:00Added an answer on May 15, 2026 at 10:39 am

    You can set if the validators are “active” or not with client side code using the ValidatorEnable function. Basically it goes like this

    var validator = document.getElementById('<%=Validator1.ClientID%>');
    ValidatorEnable(validator , state); //where state is boolean
    

    You can also trigger the validator to validate on some event (like for example the click of the buttons) using the ValidatorValidate(validator) function.

    I am not sure which would work better for you (enabling/disabling the validators or custom triggering of the validation) but I suggest this article that will guide you in the right direction

    ASP.NET Validation in Depth

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If the question is "can I convert a serialized list… May 15, 2026 at 1:22 pm
  • Editorial Team
    Editorial Team added an answer There was the problem enabling the jquery UI required for… May 15, 2026 at 1:22 pm
  • Editorial Team
    Editorial Team added an answer 99% sure will not work if js is disabled. As… May 15, 2026 at 1:22 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.