title: Adding jQuery conditional validation to dynamically-generated HTML
body: <p>I have the following HTML scenario:</p>
  
  <pre><code>&lt;div&gt;
      &lt;input id="txt0" type="text" /&gt;&lt;input type="checkbox" id="chk0" /&gt;&lt;/div&gt;
  &lt;div&gt;
      &lt;input id="txt1" type="text" /&gt;&lt;input type="checkbox" id="chk1" /&gt;&lt;/div&gt;
  &lt;!-- etc --&gt;
  &lt;div&gt;
      &lt;input id="txtN" type="text" /&gt;&lt;input type="checkbox" id="chkN" /&gt;&lt;/div&gt;
  </code></pre>
  
  <p>If checkbox <em>N</em> is checked, then textbox <em>N</em> is a mandatory field.</p>
  
  <p>I've just started to work with a (the?) <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">jQuery validation</a> module and am trying to figure out how to achieve this validation, which seems just that bit more complex than the examples.</p>
  
  <p>Conceptually I think I want to add a CSS class to my checkboxes, then use <code>addClassRules</code> to add a custom rule. However, the challenge is how to specify the relevant textbox for each checkbox.</p>
  
  <p>My HTML is generated using ASP.NET MVC, so I could dynamically generate the JavaScript that would specify a rule for each checkbox, but this seems a bit long-winded.</p>