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. Each row is a form. I want
I have a table with arbitrary columns and rows. This fact is irrelevant though
I have a databases table with ~50K rows in it, each row represents a
I have an HTML table in which the first column's cells each contain a
I have this html table where I have one cell in the table with
I have a large table with 27 columns and between 5 to 100 rows.
I have table rows of data in html being filled from a CGI application.
I have table inside a div tab. The table has 40 rows in it
I have a table with N rows, and I wanna select N-1 rows. Suggestions
I have two functions to add and remove table rows that contain a form

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.