title: Jquery validation - Error on adding rules to input element?
body: <p>I am trying to implement Jquery validation with <a href="http://docs.jquery.com/Plugins/Validation">http://docs.jquery.com/Plugins/Validation</a> :</p>
  
  <p><strong>My design plan:</strong></p>
  
  <ul>
  <li><p>My <strong>input</strong> element:</p>
  
  <pre><code>&lt;form action="submit.php" id="form_id"&gt;
    &lt;input type="text" class="val-req" id="my_input" name="myval" /&gt;
    &lt;input type="button" onclick="validate_form('form_id', function() { $('#form_id').submit(); })" /&gt;
    &lt;span id="val-msg" class="my_input"&gt;&lt;/span&gt;
  &lt;/form&gt;
  </code></pre></li>
  <li><p>Then, on dom ready:</p>
  
  <pre><code>  $(document).ready(function() {
                        $('.val-req').rules('add', {required:true});
                     });
  </code></pre></li>
  <li><p>Validate method:</p>
  
  <pre><code> function validate_form(form_id, callback) {
         var form = $('#'+form_id);
         $('.val-req').each(function() {$(this).rules('add', {required:true});});
         $(form).validate({
                  errorElement: "span",
                  errorClass:   "val-error",
                  validClass:   "val-valid",
                  errorPlacement: function(error, element) {
                                        $('#val-msg.'+$(element).attr('id')).innerHTML(error.html());
                                 },
                  submitHandler: callback
         });
   }
  </code></pre></li>
  </ul>
  
  <p>As per my expectations, it should display error message in the place holder span in the form.</p>
  
  <p>But, <strong>Problem</strong></p>
  
  <blockquote>
    <p><strong>Error on Chrome-Console</strong>: Uncaught TypeError: Cannot read property 'settings' of undefined</p>
  </blockquote>
  
  <p>It is also giving error on other browsers.
  Then, I tried to figure-out the problem and found:</p>
  
  <pre><code> $('.val-req').rules('add', {required:true});   # This is causing the error
  </code></pre>
  
  <p>As, per my understanding and documentation -> This should be correct.</p>
  
  <p>Why would this cause the TypeError and what can I do to resolve it? </p>