Skip to content

Commit b195d39

Browse files
author
Rafael J. Staib
committed
Add advanced form demo
1 parent 94287ab commit b195d39

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

advanced-form.html

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,35 @@ <h2>A powerful jQuery wizard plugin that supports accessibility and HTML5.</h2>
5454
transitionEffect: "slideLeft",
5555
onStepChanging: function (event, currentIndex, newIndex)
5656
{
57+
// Allways allow previous action even if the current form is not valid!
58+
if (currentIndex > newIndex)
59+
{
60+
return true;
61+
}
62+
63+
// Forbid next action on "Warning" step if the user is to young
64+
if (newIndex === 3 && Number($("#age").val()) < 18)
65+
{
66+
return false;
67+
}
68+
5769
$("#form").validate().settings.ignore = ":disabled,:hidden";
5870
return $("#form").valid();
5971
},
72+
onStepChanged: function (event, currentIndex, priorIndex)
73+
{
74+
// Used to skip the "Warning" step if the user is old enough.
75+
if (currentIndex === 2 && Number($("#age").val()) >= 18)
76+
{
77+
$("#form").steps("next");
78+
}
79+
80+
// Used to skip the "Warning" step if the user is old enough and wants to the previous step.
81+
if (currentIndex === 2 && priorIndex === 3)
82+
{
83+
$("#form").steps("previous");
84+
}
85+
},
6086
onFinishing: function (event, currentIndex)
6187
{
6288
$("#form").validate().settings.ignore = ":disabled";
@@ -90,7 +116,6 @@ <h4>Account</h4>
90116
<input id="password" name="password" type="text" class="required"><br>
91117
<label for="confirm">Confirm Password *</label><br>
92118
<input id="confirm" name="confirm" type="text" class="required"><br>
93-
<input id="specialRole" name="specialRole" type="checkbox"> <label for="specialRole">Special User Role (if activated you will enter the hint step after profile step)</label><br>
94119
<p>(*) Mandatory</p>
95120
</fieldset>
96121

@@ -106,16 +131,16 @@ <h4>Profile</h4>
106131
<input id="email" name="email" type="text" class="required email"><br>
107132
<label for="address">Address</label><br>
108133
<input id="address" name="address" type="text"><br>
134+
<label for="age">Age (Hint page will show up if age is less than 18) *</label><br>
135+
<input id="age" name="age" type="text" class="required number"><br>
109136
<p>(*) Mandatory</p>
110137
</fieldset>
111138

112-
<h4>Hints</h4>
139+
<h4>Warning</h4>
113140
<fieldset>
114-
<legend>Hints</legend>
115-
116-
<p>You are a special user because of your role! That's why you see this content.</p>
141+
<legend>You are to young</legend>
117142

118-
<input id="readHint" name="readHint" type="checkbox" class="required" disabled> <label for="readHint">I have read that and agree.</label>
143+
<p>Please go away ;-)</p>
119144
</fieldset>
120145

121146
<h4>Finish</h4>

basic.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h4>Other demos</h4>
6969
<li>Async Example</li>
7070
<li><a href="iframe.html">Embedded Iframe Example</a></li>
7171
<li><a href="basic-form.html">Basic Form Example</a></li>
72-
<li>Advanced Form Example</li>
72+
<li><a href="advanced-form.html">Advanced Form Example</a></li>
7373
<li><a href="add-remove.html">Dynamic Manipulation Example</a></li>
7474
<li>Pagination Example</li>
7575
<li><a href="tabs.html">Tabs Example</a></li>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h3>Overview</h3>
5252
<li>Async Example</li>
5353
<li><a href="iframe.html">Embedded Iframe Example</a></li>
5454
<li><a href="basic-form.html">Basic Form Example</a></li>
55-
<li>Advanced Form Example</li>
55+
<li><a href="advanced-form.html">Advanced Form Example</a></li>
5656
<li><a href="add-remove.html">Dynamic Manipulation Example</a></li>
5757
<li>Pagination Example</li>
5858
<li><a href="tabs.html">Tabs Example</a></li>

tabs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h4>Other demos</h4>
8585
<li>Async Example</li>
8686
<li><a href="iframe.html">Embedded Iframe Example</a></li>
8787
<li><a href="basic-form.html">Basic Form Example</a></li>
88-
<li>Advanced Form Example</li>
88+
<li><a href="advanced-form.html">Advanced Form Example</a></li>
8989
<li><a href="add-remove.html">Dynamic Manipulation Example</a></li>
9090
<li>Pagination Example</li>
9191
<li>Multiple Wizard Example</li>

0 commit comments

Comments
 (0)