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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:12:40+00:00 2026-05-22T12:12:40+00:00

I have a page with 3 tables: <table id=t1> <tr> <td></td><td><input type=text name=name /></td>

  • 0

I have a page with 3 tables:

<table id="t1">
  <tr>
    <td></td><td><input type="text" name="name" /></td>
    <td></td><td><input type="text" name="id" /></td>
    <td></td><td><input type="text" name="perDate" /></td>
    <td></td><td><input type="text" name="email" /></td>
  </tr>
</table>

<table id="t2">
  <tr>
    <td></td><td><input type="text" name="lostFound"  /></td>
    <td></td><td><input type="text" name="lostDate" /></td>
    <td></td><td><input type="text" name="item" /></td>
  </tr>
</table>

<table id="t3">
  <tr>
    <td></td><td><input type="text" name="check" /></td>
    <td></td><td><input type="text" name="reason" /></td>
    <td></td><td><input type="text" name="chkDate" /></td>
  </tr>
</table>

So, I have a validation script where if I just change the class to ‘required’ then it will make that input field required. The problem I am having is….I only want to require a field if another field in that table is filled out, otherwise the field is not required. Ex: If t1 – name is filled in then I want to change the class of t1 – id, t1 – perDate, and t1 – email to ‘required’, and leave all of the other classes for t2 and t3 untouched. I was wondering if someone could point me in the right direction with some sort of javascript code that would make this possible. thanks for all the help, and if more info is needed, please ask.

  • 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-22T12:12:41+00:00Added an answer on May 22, 2026 at 12:12 pm

    So when you blur out of the “Name” input, you require the adjacent inputs to be required if they provided a name. But also don’t forget to make them not required if they go back and decide to clear that name field like so:

    $('.t1 input[name=name]').blur(function(){
        var $depends = $('.t1 input[name=id], .t1 input[name=perDate], .t1 input[name=email]');
        if($(this).val() != "")
            $depends.addClass('required');
        else
            $depends.removeClass('required');
    });
    

    Also, if you’re trying to change the required attribute if any of the controls have data, you would do something like this:

    //blur even on each input in t1
    $('.t1 input').blur(function(){
        //store as variable
        var $t1in = $('.t1 input');
        var hasData = false;
        //check all inputs and if one has data, set variable and exit
        $t1in.each(function(){
            if($(this).val().length > 0){
                hasData = true;
    
                //exit loop
                return false;
            }
        });
        //if any of the controls has data
        if(hasData)
            $t1in.addClass('required');
        else
            $t1in.removeClass('required');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table inside a form that looks as follows: <td><input type=text name=code[0]
I have a form written below: <table> <tr> <td>Worker Type:</td> <td><input type=text id=WorkerTypeTB/></td> </tr>
I have xpath page.search(//table[@class='campaign']//table) which returns two tables. I need to choose only first
I want to place a table on my page. I have two tables in
I have stored page contents (tables, plain text, images and paragraphs) into a variable.
I have a page with several tables on it with the same class name.
I have a simple table for reference page: id name description image In reference.php,
I have the following page: <div style=display: inline> <input type=button id=txt value=Add TextBox style=
I have a page with a table of stuff and I need to allow
I have a page with a table, say: <table> <tr><td>Element1</td></tr> <tr><td>Element2</td></tr> </table> I am

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.