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

  • SEARCH
  • Home
  • 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 7628827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:40:23+00:00 2026-05-31T05:40:23+00:00

I am using JQuery to hide/show a div depending on the selected value of

  • 0

I am using JQuery to hide/show a div depending on the selected value of a combo box. This part works fine. However, when hiding the div, the jquery function should also disable 3 RequiredFieldValidators which are in that div. I’ve been looking online and it seems that this can easily be accomplished using:

ValidatorEnable(ValidatorName, false);

But when I try using that method, nothing works, the RequiredFieldValidators still display an error even though the div is hidden.

My JQuery function:

<script type="text/javascript">
        $(document).ready(function () {
            var det = $("#SponsorDetails");
            $(det).hide();
            var all = $("#AllDetails");
            $(all).hide();

            $("#<%=SelectAccount.ClientID %>").click(function () {
                //hide social worker and sponsor stuff
                var value = $("#<%=SelectAccount.ClientID %> option:selected").val();
                if (value == "Social_Worker") {
                    //show social worker stuff
                    $("#AllDetails").show("slow");
                    $("#SponsorDetails").hide("slow");
                    ValidatorEnable(document.getElementById("#<%=AddressValidator.ClientID %>"), false);
                    ValidatorEnable(document.getElementById("#<%=CityValidator.ClientID %>"), false);
                    ValidatorEnable(document.getElementById("#<%=CountryValidator.ClientID %>"), false);

                } else if (value == "Sponsor") {
                    //show sponsor stuff
                    $("#AllDetails").show("slow");
                    $("#SponsorDetails").show("slow");
                    ValidatorEnable(document.getElementById("#<%=AddressValidator.ClientID %>"), true);
                    ValidatorEnable(document.getElementById("#<%=CityValidator.ClientID %>"), true);
                    ValidatorEnable(document.getElementById("#<%=CountryValidator.ClientID %>"), true);

                }
            });

        });


    </script>

Someone suggested I could use Validation groups or a custom validator, but using jquery just seems much simpler but I don’t know why it won’t work.

  • 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-31T05:40:25+00:00Added an answer on May 31, 2026 at 5:40 am

    You have confuze the jQuery with the simple javascript. In simple javascript we do not use the symbol # in front of the element id. So remove it from all the getElementById function and it will work.

    For example

    document.getElementById("<%=CountryValidator.ClientID %>")
    

    The error you get is because you call getElementById with out check the return of them, so you get throw error from the use of the return of this function that can not be use.

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

Sidebar

Related Questions

I'm using .NET 4 and JQuery to show/hide Div's depending on what's selected from
I am using jQuery to show/hide a div container (#pluginOptionsContainer), and load a page
I'm using this jquery code to show and hide divs on my page. As
I'm using this jQuery to hide a DIV: $(#slider).click(function() { $(.help).slideToggle(); $(#wrapper).animate({ opacity: 1.0
Im trying to show/hide a div using jquery when a link gets clicked. I
i'm using jquery toggle to show/hide a div on different links. It shows/hides them
Am using jquery to show a div on click and to hide it when
I need to show/hide some divs depending on selected options. I'm using .change function.
Given this last thread: Javascript/Jquery: Show a hidden div based on a Radio box
Trying to show/hide severals divs using jquery after each news on my page. <div

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.