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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:23:01+00:00 2026-05-25T11:23:01+00:00

I have these inputs and checkbox in a form <input class=validate[minCheckbox[1]] checkbox id=maxcheck_0 type=checkbox

  • 0

I have these inputs and checkbox in a form

<input class="validate[minCheckbox[1]] checkbox" id="maxcheck_0" type="checkbox" name="children[]" value="Juliette" />
<input type="text" name="school[]" id="school_0" value="" /><br />
<input class="validate[minCheckbox[1]] checkbox" id="maxcheck_1" type="checkbox" name="children[]" value="Franck" />
<input type="text" name="school[]" id="school_1" value="" /><br />
<input class="validate[minCheckbox[1]] checkbox" id="maxcheck_2" type="checkbox" name="children[]" value="Lisa" />
<input type="text" name="school[]" id="school_2" value="" />

and this jquery to bind the checkbox click

    $('input[type=checkbox]').bind('click',function() {
    if($(this).is(':checked')){
        $('#school_0').attr('class', 'validate[required]');
        //$('#school_1').attr('class', 'validate[required]');
        //$('#school_2').attr('class', 'validate[required]');
    } else {
        $('#school_0').removeAttr('class');
        //$('#school_1').removeAttr('class');
        //$('#school_2').removeAttr('class');
    }
}); 

How can I add a class attribute to any input related to its checkbox ?

  • 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-25T11:23:02+00:00Added an answer on May 25, 2026 at 11:23 am

    If all your checkboxes are have ids formated like this “maxcheck_” + some integer and all the associated textboxes are associated according to the integer listed in the checkboxes id. Then you can:

    Get the id of the clicked checkbox. split() that string at the _ and access the value in the 2nd position of the array. Using the value from the second position of the array you can then add it to the end of “school_” to modify the correct textbox.

    $('input[type=checkbox]').bind('click',function() {
        if($(this).is(':checked')){
            var idnum = (($(this).attr("id")).split("_"))[1];
            $('#school_ ' + idnum).addClass('validate[required]');
        } else {
            $('#school_' + idnum).removeClass('validate[required]');
        }
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dijit.form.NumberTextBox input field that starts out with these parms: new dijit.form.NumberTextBox({
I'm generating an html file which looks like: <tr id=ID001 property1=PROPERTY001><td><input type=checkbox name=row_checkbox_ID001></td><td>...</td><td>...</td></tr> <tr
I have a form (todo list) containing labels/checkboxes (todos) as follows: <form class=tasklist> These
I have code like so: <form enctype=multipart/form-data method=POST action=blabla.php class=addToCart> <input type=button onclick=addToCartMulti(); value=Add
I have a form with elements like: <div class=row1> <select name=someSelectField multiple=multiple class=selectList> <option
I have a table with a lot of text inputs like these: alt text
I have writtent some Oracle storedprocedures in these there are more then 20 input
I have a form input , and the label spans multiple lines, and I
I have a simple form in ASP.NET MVC. I am trying to post these
As you see I have class whose name is table; and I have many

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.