title: jQuery validate less than
body: <p>I am trying to write a <code>Less than</code> validator for jQuery.  </p>
  
  <p>I want to compare one text box against another, so if I have:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="text" id="value1" /&gt; &lt;input type="text" id="value2" /&gt;
  </code></pre>
  
  <p>I want my <code>validator</code> to look like</p>
  
  <pre class="lang-js prettyprint-override"><code>$('#myForm').validate({rules: { value1: { lessThan: "#value2" } } });
  </code></pre>
  
  <p>I have tried this but I can't get it to work:</p>
  
  <pre class="lang-js prettyprint-override"><code>$.validator.addMethod('lessThan', function(value, element, param) {
      var i = parseInt(value);
      var j = parseInt($(param).val());
      return i &gt;= j;
  }, "Less Than");
  </code></pre>
  
  <p>Another question is where should I put that code?  In <code>$(document).ready</code> or just in a <code>&lt;script&gt;</code> tag?</p>