title: Extra parameter in jquery validation
body: <p>I'm using the jquery validation in a somewhat complicated form. The validation rules are added in code by assigning classes to form-fields, but I can't seem to get it working with an extra parameter. I'm not having much luck with the jQuery documentation I'm afraid.</p>
  
  <p>Below is an example of what does work for me, and what doesn't, the example is obviously not very useful.</p>
  
  <hr>
  
  <p><strong>Working</strong> (shows error on anything but <code>a</code>)</p>
  
  <p>(pseudo-code)</p>
  
  <pre><code>$fieldXclasses = "myrule";
  </code></pre>
  
  <p>generated HTML</p>
  
  <pre><code>&lt;input id="x" name="x" value="fromdatabase" class="myrule error" type="text"&gt;
  </code></pre>
  
  <p>js method:</p>
  
  <pre><code>jQuery.validator.addMethod("myrule", function(value, element) { 
      return this.optional(element) || /^a$/.test(value);
  }, "Please enter 'a'");  
  </code></pre>
  
  <p>It has "error" as extra class as 'fromdatabase' is obviously not <code>a</code>, so it fails the "myrule" function. When I type <code>a</code> in the field it changes to <code>class="docnmr valid"</code> as expected. My conlcusion from this is that my validation set-up is working for the simple cases, so I don't need to look for errors in how I load the validation-plugin.</p>
  
  <hr>
  
  <p><strong>Not working:</strong></p>
  
  <p>(pseudo-code)</p>
  
  <pre><code>$fieldXclasses = "myrule:1";
  </code></pre>
  
  <p>generated HTML</p>
  
  <pre><code>&lt;input id="x" name="x" value="fromdatabase" class="myrule:1 valid" type="text"&gt;
  </code></pre>
  
  <p>js method:</p>
  
  <pre><code>jQuery.validator.addMethod("myrule", function(value, element,param) { 
      return this.optional(element) || /^a$/.test(value);
  }, "Please enter 'a'");  
  </code></pre>
  
  <p>Now the initial state is wrong from start: it should be error instead of valid, as it doesn't meet the requirements. I'm assuming the class <code>myrule:1</code> isn't parsed as something that calls the <code>myrule</code> function with <code>1</code> as parameter. But this is what I thought was the way to add a parameter, though I cannot find the correct method very easily in the jquery-documentation.</p>
  
  <p><strong>Can anyone enlighten my on how to add an extra paramter?</strong></p>
  
  <p><em>For background: in the end the goal is to use another fields value as parameter, because they depend on eachother. Another option might certainly be to forget about the the parameter and us the <code>this</code> object in the rule to find the correct field. Not sure if that's feasible though.</em></p>