title: Dynamically setting rules/messages objects for jQuery validation plugin
body: <p>I'm sure there's a better way to implement this but can't figure it out. I have a form which has 2 fields at the top that are always required. I then have a series of tabs which load in different fields when selected (separate chunks of HTML loading in, so that only what's currently in the DOM is submitted when the form submits). I'm using the jquery validation plugin ( <a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow">http://docs.jquery.com/Plugins/Validation</a> ) which allows you to set the validation rules/messages as an object when each set of new fields loads in, to remove redundant rules and add new ones as the fields change. Problem is the rules/messages objects all have to be written into the js for use when required and the file is long and it seems very inefficient. Here's my pseudocode:</p>
  
  <pre><code>&lt;form&gt;
      &lt;input1 (always on page) /&gt;
      &lt;input2 (always on page) /&gt;
      &lt;ul id="nav-tabs"&gt;
          &lt;li id="tab1"&gt;&lt;/li&gt;
          &lt;li id="tab2"&gt;&lt;/li&gt;
          &lt;li id="tab3"&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;div id="dynamic-content"&gt;
          &lt;!-- different form fields load in here from separate html files, all requiring different rules in addition to the 2 fields always on the page --&gt;
      &lt;/div&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I'm thinking there might be some solution with loading in the rules with each chunk of HTML as it is set?  Has anyone done anything like this?</p>
  
  <p>Thanks to anyone who can help.
  T </p>