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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:48:58+00:00 2026-05-15T08:48:58+00:00

I have a table with 5 rows and 2 columns. Each cell contains a

  • 0

I have a table with 5 rows and 2 columns. Each cell contains a text box. I want to show error if one of the text boxes in each column is empty. I want both text boxes in a row shld be filled or both shld empty.

How can i do this via Asp.net validation controls?

I want to extend CompareValidator so that it will validate only if the controlToValidate and controlToCompare both have some text in it or both are empty.

  • 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-15T08:48:59+00:00Added an answer on May 15, 2026 at 8:48 am

    You would need to use a CustomValidator and handle its ServerValidate event (and, optionally, its ClientValidationFunction for client-side validation). You could do one on the page and check all the rows, or you could have one per row and use the ControlToValidate property to give you context to the row you’re validating.

    Any example of the client-side validation is going to depend on your layout and any JavaScript framework that you’re using. It might look something like this:

    <table>
        <tr>
            <td><asp:TextBox runat="server" ID="TextBox11" /></td>
            <td><asp:TextBox runat="server" ID="TextBox12" /></td>
        </tr>
        <tr>
            <td><asp:TextBox runat="server" ID="TextBox21" /></td>
            <td><asp:TextBox runat="server" ID="TextBox22" /></td>
        </tr>
        <tr>
            <td><asp:TextBox runat="server" ID="TextBox31" /></td>
            <td><asp:TextBox runat="server" ID="TextBox32" /></td>
        </tr>
        <tr>
            <td><asp:TextBox runat="server" ID="TextBox41" /></td>
            <td><asp:TextBox runat="server" ID="TextBox42" /></td>
        </tr>
        <tr>
            <td><asp:TextBox runat="server" ID="TextBox51" /></td>
            <td><asp:TextBox runat="server" ID="TextBox52" /></td>
        </tr>
    </table>
    <asp:CustomValidator ID="TextBoxPairValidator" runat="server" ControlToValidate="TextBox11" ClientValidationFunction="TextBoxPairValidator_ClientValidate" />
    
    <script type="text/javascript">
        (function () {
            window.TextBoxPairValidator_ClientValidate = function (sender, args) {
                var other = document.getElementById(sender.id.slice(0, -1) + '2');
                args.IsValid = (sender.value === '' && other.value === '')
                               || (sender.value !== '' && other.value !== '');
            };
        }());
    </script>
    

    That example obviously assumes a fairly simple layout, and fairly static naming (i.e. if your controls are in a naming container, you may not be able to use the ID trick to go from one text box to the other). Hopefully that’s enough to get you started.

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

Sidebar

Related Questions

I have a table with multiple rows and columns and each cell contains a
I have a table with one column and four rows. Each tr has a
I have a really simple table with two rows and two columns. I want
I have a table with a few thousand rows. The table contains two columns,
I have a SQL Server database table with a column called resources. Each cell
I have a cell Table in GWT with columns , there are 3 rows
I have three tables with 5 columns each. They can grow upto 15 rows
I have table of 5000+ rows and 8+ columns like, Station Lat Long Date
We have a large table (450 million rows containing 34 columns of numeric or
I have a table with ~200 million rows and ~15 columns in it. I

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.