Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are lots of ways to do this, but the demo below also contains a large part of the answer to your question, which would be to use the <code>.valid()</code> method to programatically test the form. You can use my example below in whole or in part.</p> <hr> <p>When I create multi-step forms, I use a unique set of <code>&lt;form&gt;</code> tags for each section. Then I use <a href="http://jqueryvalidation.org/valid" rel="nofollow noreferrer">the <code>.valid()</code> method</a> to test the section before moving to the next. <em>(Don't forget to first initialize the plugin; call <code>.validate()</code>, on all forms on DOM ready.)</em></p> <p>Then on the last section, I use <code>.serialize()</code> on each form and concatenate them into a data query string to be submitted.</p> <p>Something like this...</p> <pre><code>$(document).ready(function() { // &lt;-- DOM ready handler $('#form1').validate({ // initialize form 1 // rules }); $('#gotoStep2').on('click', function() { // go to step 2 if ($('#form1').valid()) { // code to reveal step 2 and hide step 1 } }); $('#form2').validate({ // initialize form 2 // rules }); $('#gotoStep3').on('click', function() { // go to step 3 if ($('#form2').valid()) { // code to reveal step 3 and hide step 2 } }); $('#form3').validate({ initialize form 3 // rules, submitHandler: function (form) { // serialize and join data for all forms var data = $('#form1').serialize() + '&amp;' + $('#form2').serialize() + '&amp;' + $(form).serialize() // ajax submit return false; // block regular form submit action } }); // there is no third click handler since the plugin takes care of this // with the built-in submitHandler callback function on the last form. }); </code></pre> <p>Important to remember that my <code>click</code> handlers above are not using <code>type="submit"</code> buttons. These are regular buttons, either <em>outside</em> of the <code>form</code> tags or <code>type="button"</code>.</p> <p>Only the button on the very last form is a regular <code>type="submit"</code> button. That is because I am leveraging the plugin's built-in <code>submitHandler</code> callback function on only the very last form.</p> <p><strong>"Proof of Concept" DEMO: <a href="http://jsfiddle.net/dNPFX/" rel="nofollow noreferrer">http://jsfiddle.net/dNPFX/</a></strong></p> <p>Also, see for reference:</p> <p><a href="https://stackoverflow.com/a/19546698/594235">https://stackoverflow.com/a/19546698/594235</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload