Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This might give you a nice starting point: <strong><a href="http://jsfiddle.net/WYhNm/2/" rel="nofollow">Fiddle</a></strong></p> <p>Add a <code>step</code> class to each of your form elements (I do believe for this to work they need to be each other's siblings):</p> <pre><code>&lt;form class="step-by-step"&gt; &lt;!-- Start with only the first one enabled --&gt; &lt;input type="text" class="step" id="step1" /&gt; &lt;input type="text" class="step" id="step2" disabled /&gt; &lt;input type="text" class="step" id="step3" disabled /&gt; &lt;!-- Also works with selects, as long as you keep track of IDs --&gt; &lt;select id="step4" class="step" disabled&gt; &lt;option value=""&gt;Choose one&lt;/option&gt; &lt;option value="volvo"&gt;Volvo&lt;/option&gt; &lt;option value="saab"&gt;Saab&lt;/option&gt; &lt;option value="mercedes"&gt;Mercedes&lt;/option&gt; &lt;option value="audi"&gt;Audi&lt;/option&gt; &lt;/select&gt; &lt;select id="step5" class="step" disabled&gt; &lt;option value=""&gt;Choose one&lt;/option&gt; &lt;option value="europe"&gt;Europe&lt;/option&gt; &lt;option value="america"&gt;America&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>Then, use the <code>next()</code> function to find the next step in the form when something changes, and either disable or enable it (or all next steps, if the element was empty):</p> <pre><code>// The change event is fired when a form element loses focus // and its value has changed since the last time we interacted with it $('.step').change(function() { var next_step = $(this).next('.step'); var all_next_steps = $(this).nextAll('.step'); // If the element *has* a value if ($(this).val()) { // Should also perform validation here next_step.attr('disabled', false); } // If the element doesn't have a value else { // Clear the value of all next steps and disable all_next_steps.val(''); all_next_steps.attr('disabled', true); } }); </code></pre> <p>For TAB functionality, the following is a quick fix, which I'm sure can be somehow integrated with the above function.</p> <pre><code>$('.step').keydown(function(event) { // If they pressed tab AND the input has a (valid) value if ($(this).val() &amp;&amp; event.keyCode == 9) { $(this).next('.step').attr('disabled', false); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    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