title: jQuery Mobile validation plugin
body: <p>I've been trying without much success to validate mobile forms using the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow noreferrer">jQuery validation plugin</a>.</p>
  
  <p>It seems as though the first page I visit that has a form validates ok.
  Subsequent pages don't validate, unless they have the same fields that were present for validation on the first page.</p>
  
  <p>For example, the first page I visit is the login page. It has 2 fields, email address and password.</p>
  
  <p>The code is:</p>
  
  <pre><code>&lt;body&gt;
  &lt;div id="Login" data-role="page"&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).on('pageinit pageshow', 'div:jqmData(role="page"), div:jqmData(role="dialog")', function(){
      if($("form.validate").length &gt; 0){
        $("form.validate").validate({
  
          rules: {
            email_address: {
              required: true,
              email: true
            },
            password: "required"
          }
  
        });
      }
    });
  &lt;/script&gt;
  
  &lt;form name="login" method="post" class="validate"&gt;
  
    &lt;label class="inputLabel" for="login-email-address"&gt;Email Address:&lt;/label&gt;
    &lt;input type="email" name="email_address" size="18" id="login-email-address" /&gt;
    &lt;label class="inputLabel" for="login-password"&gt;Password:&lt;/label&gt;
    &lt;input type="password" name="password" size="18" id="login-password" /&gt;
  
    &lt;input type="submit" value="Log In" data-icon="lock" data-mini="true" alt="Log In" title=" Log In " /&gt;
  
  &lt;/form&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>This validates when I hit the submit button.
  If I hit the button from the login page to go to the create account page, which has 4 fields - first name, last name, email address &amp; password only the email address and password validate.</p>
  
  <p>The create account page looks like this:</p>
  
  <pre><code>&lt;body&gt;
  &lt;div id="CreateAccount" data-role="page"&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).on('pageinit pageshow', 'div:jqmData(role="page"), div:jqmData(role="dialog")', function(){
      if($("form.validate").length &gt; 0){
        $("form.validate").validate({
  
          rules: {
            firstname: {
              required: true,
              minlength: 2
            },
            lastname: {
              required: true,
              minlength: 2
            },
            email_address: {
              required: true,
              email: true
            },
            password: "required"
          }
  
        });
      }
    });
  &lt;/script&gt;
  
  &lt;form name="create_account" method="post" class="validate"&gt;
  
    &lt;label class="inputLabel" for="create-account-firstname"&gt;First Name:&lt;/label&gt;
    &lt;input type="text" name="firstname" size = "41" maxlength= "96" id="create-account-firstname" /&gt;
    &lt;label class="inputLabel" for="create-account-lastname"&gt;Last Name:&lt;/label&gt;
    &lt;input type="text" name="lastname" size = "41" maxlength= "96" id="create-account-lastname" /&gt;
    &lt;label class="inputLabel" for="create-account-email-address"&gt;Email Address:&lt;/label&gt;
    &lt;input type="email" name="email_address" size="18" id="create-account-email-address" /&gt;
    &lt;label class="inputLabel" for="create-account-password"&gt;Password:&lt;/label&gt;
    &lt;input type="password" name="password" size="18" id="create-account-password" /&gt;
    &lt;input type="submit" value="Submit" data-icon="lock" data-mini="true" alt="Submit" title=" Submit " /&gt;
  
  &lt;/form&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>If I hit the submit button on this page, only the email address and password are validated. I'm presuming this is because it is still running the validation rules from the login page rather than the create account page? If I hit the browser refresh, then the submit button all 4 fields are validated.</p>
  
  <p>How can I get the forms validating correctly?</p>