title: JQuery validator plugin - Validating that an element exists
body: <p>I need to validate a form that uses hidden inputs for a set of values that get created dynamically. These hidden inputs don't exist on an empty form but I want to ensure that at least one is created before the form can be submitted. </p>
  
  <p>The validator plugin requires an existing element to attach a rule to it. Is there anyway way to attach a rule to a selector or something similar that would test if an element exists? </p>
  
  <p>The only other option I can think of is to use the submit handler to perform secondary validation.</p>
  
  <p>I'm binding the rules like this:</p>
  
  <pre><code> var elements = $("#" + formId + ' [name=\"' + name + '\"]');
          if(elements.length &gt; 0){
              elements.each(function(i){
                  $(this).rules("add", {
                      required: true
                  });
              });
          }
  </code></pre>
  
  <p>So there's no real way to add a rule to an element that doesn't exist yet. I can (and do) add a rule when the element is created dynamically, but how do I test if that element hasn't been created?</p>
  
  <p>Any suggestions?</p>