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 6078921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:53:17+00:00 2026-05-23T10:53:17+00:00

How can I get the parent in the asp:CustomValidator javascript function so that I

  • 0

How can I get the parent in the asp:CustomValidator javascript function so that I can used it to check whether the related checkbox have been checked?

Example:

I have the following code:

        <tr>   
            <th class="graytext r">Add Reps to Team:</th>
            <td>           
             <asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID"
                    DataSourceID="dsEmployees" EnableViewState="false"
                    GridLines="None" CssClass="clGridDirectory">
                    <Columns>
                      <asp:TemplateField >
                        <ItemTemplate>
                          <asp:CheckBox runat="server" ID="employee_name" CssClass="employee_name" Text='<%# Eval("fullname") %>'/> 
                          <asp:HiddenField runat="server" ID="employeeidToRep" Value='<%# Eval("employeeid") %>'/>

                          <asp:TextBox runat="server" ID="repID" Text='<%# Eval("rep_id") %>'  />

                            <asp:CustomValidator id="CustomValidator2" runat="server" 
                              ControlToValidate = "repID"
                              ErrorMessage = ""
                              ClientValidationFunction="test" >
                            </asp:CustomValidator>
                        </ItemTemplate>
                      </asp:TemplateField>
                    </Columns>
                  </asp:GridView>       
               <asp:SqlDataSource ID="dsEmployees" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
                    SelectCommand="app_staff_without_team_select" SelectCommandType="StoredProcedure">
              </asp:SqlDataSource>        
            </td>
        </tr>

Jquery code:

function test(oSrc, args) {

    var $tb = $('input[id$=employee_name]');
    // only validate if an <asp:Checkbox> called chkOtherCheckbox is ticked
    alert(args.Value.toString())
    if ($('input:checkbox[id$=chkOtherCheckbox]').is(':checked'))
        alert('checked')
    else
        alert('no checked')

}

How can I get the parent in the test function so that I can used it to check whether the related checkbox have been checked?

  • 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-23T10:53:18+00:00Added an answer on May 23, 2026 at 10:53 am

    You can use this code for getting the state of nearest checkbox.

    function test(oSrc, args) {    
       var nearestCheckBox= $(oSrc).parent().find('input:checkbox:first');
                var state=nearestCheckBox.attr('checked');//use this variable
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Logging can get complicated, quickly. Considering that you have some code, how do you
I have an ASP.NET user control that is used in another use control. The
I have asp.net form that contains fields. When I access this window, my javascript
I have the following ASP classic function: function get_children(n) dim local_array dim parent dim
how can i get immediate parent of a given element ? $(e.target).parent() ?
In jQuery you can get the top position relative to the parent as a
I have the following ASP.NET markup: <div id=myForm title=My Form style=display: none> <span>You can
If I have the following CheckBoxList <asp:CheckBoxList ID=typeCheckBoxList runat=server RepeatDirection=Horizontal> <asp:ListItem Value=0>Student</asp:ListItem> <asp:ListItem Value=1>Parent</asp:ListItem>
I have a structure that looks following Class TreeNode { public TreeNode Parent {
I'm trying to get an ASP.NET MVC app working... I should have known it

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.