Translate function into a new validation rule

Translate function into a new validation rule

I wrote a function to validate a section of a form.  The intention is, when the form submit button is clicked, ensure there are at least 3 rows in the table, if the radio button with a value of true is clicked.  

Here is the basic HTML structure:

  1. <form id="MyForm" action="/" method="post">    

  2.     <div class="Question">
  3.         <div class="RadioBtns">
  4.             <input type="radio" id="Radio_Yes" name="Radio1" value="true" />Yes
  5.             <input type="radio" id="Radio_No" name="Radio1" value="false" />No
  6.         </div>
  7.         <div class="TextFields">
  8.             <input type="text" id="field1" />
  9.             <input type="text" id="field2" />
  10.             <input type="text" id="field3" />       
  11.         </div>
  12.         <table id="Table1" class="Data-Table">
  13.             <tr>
  14.                 <th>Name</th>
  15.                 <th>Age</th>
  16.             </tr>
  17.             <tr>
  18.                 <td colspan=2>No Data Entered</td>
  19.             </tr>
  20.         </table>
  21.     </div>
  22.     <p>
  23.         <input type="submit" value="Add to Database" />
  24.     </p>
  25. </form>


Here is the function:

  1.     $(document).ready(function () {
  2.         $("#SendBtn").click(function () {
  3.             var rows = $("#Table1 tr").length;
  4.             if ($("#Radio_Yes:checked") && (rows < 3))
  5.                 {
  6.                     $(this).closest("div.TextFields").css("backgroundcolor: #ff0000;");
  7.                 }
  8.             });
  9.         });

It doesn't work and not sure why, but not really a big deal because I need to translate this into a new validation rule anyway.  I am looking at doing something like:

  1. $("#TxtFld").rules("add", {
  2.        required: "#Radio_Yes:checked"
  3.     });
but that also isn't working, so some help would be great.  The other issue ios I actually have 7 ".Question" classes, so I am hoping to have one rule that will apply to all questions.

Here is the basic html structure: