Validator - add a 'RequiredIf' method/rule

Validator - add a 'RequiredIf' method/rule

I am working on an ASP MVC3 project, using validate and unobtrusive jquery.  I have several area on a page that I need to create custom validation for, and ensure it doesn't break anything else.  Currently I have several sections, each have a radio button pair, some text boxes, a button and a table.  User fills in the text boxes, hits the button, and I have a function that puts the data from the textboxes into a new row on the table.  I also have a counter that is advanced once with each button press.

The validation needs to be along the lines of "If the radio button returned true, the counter needs to be > 1.

I wrote this function that seems like it would work, but I believe I need to re-write it so it is tied into the existing validation, hence the need to add a method or rule:

  1.             $(document).ready(function () {
  2.                 $("#nextBtn").click(function () {
  3.                     var rows = $("#ROTable tr").length;
  4.                     if ($("#RO_Yes").is("checked") && (rows < 3))
  5.                         {
  6.                             $(this).closest("div.historyCollection").css("backgroundcolor: #ff0000;");
  7.                         }
  8.                     });
  9.                 });
I have looked around and I found a section in this site discussing Rules (dependant value) which seems like it may fit.  Butbecause I am pretty new to this stuff, I wanted to poll the experts before I look too hard in one direction.  Thank you for reading.

EDIT:  I have been playing around and I came up with this:


  1. $(document).ready(function () {
  2.     $("ROCounter").rules("add", {
  3.         required: $("#RO-Yes").is(":checked"),
  4.         messages: {
  5.             required: "Please enter further information"
  6.         }
  7.     });
  8. });
but it broke all the validation and caused an error in the jquery.validate.min.js file: 
" TypeError: Cannot read property 'form' of undefined"