@@ -54,9 +54,35 @@ <h2>A powerful jQuery wizard plugin that supports accessibility and HTML5.</h2>
54
54
transitionEffect : "slideLeft" ,
55
55
onStepChanging : function ( event , currentIndex , newIndex )
56
56
{
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
+
57
69
$ ( "#form" ) . validate ( ) . settings . ignore = ":disabled,:hidden" ;
58
70
return $ ( "#form" ) . valid ( ) ;
59
71
} ,
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
+ } ,
60
86
onFinishing : function ( event , currentIndex )
61
87
{
62
88
$ ( "#form" ) . validate ( ) . settings . ignore = ":disabled" ;
@@ -90,7 +116,6 @@ <h4>Account</h4>
90
116
< input id ="password " name ="password " type ="text " class ="required "> < br >
91
117
< label for ="confirm "> Confirm Password *</ label > < br >
92
118
< 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 >
94
119
< p > (*) Mandatory</ p >
95
120
</ fieldset >
96
121
@@ -106,16 +131,16 @@ <h4>Profile</h4>
106
131
< input id ="email " name ="email " type ="text " class ="required email "> < br >
107
132
< label for ="address "> Address</ label > < br >
108
133
< 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 >
109
136
< p > (*) Mandatory</ p >
110
137
</ fieldset >
111
138
112
- < h4 > Hints </ h4 >
139
+ < h4 > Warning </ h4 >
113
140
< 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 >
117
142
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 >
119
144
</ fieldset >
120
145
121
146
< h4 > Finish</ h4 >
0 commit comments