49
49
<h2 class =" page-header" >Basic Form Example</h2 >
50
50
<form id =" form-2" action =" #" >
51
51
<div id =" wizard-2" >
52
- <h4 >Account</h4 >
52
+ <h3 >Account</h3 >
53
53
<section >
54
54
<label for =" userName" >User name *</label ><br >
55
55
<input id =" userName" name =" userName" type =" text" class =" required" ><br >
60
60
<p >(*) Mandatory</p >
61
61
</section >
62
62
63
- <h4 >Profile</h4 >
63
+ <h3 >Profile</h3 >
64
64
<section >
65
65
<label for =" name" >First name *</label ><br >
66
66
<input id =" name" name =" name" type =" text" class =" required" ><br >
73
73
<p >(*) Mandatory</p >
74
74
</section >
75
75
76
- <h4 >Hints</h4 >
76
+ <h3 >Hints</h3 >
77
77
<section >
78
78
<ul >
79
79
<li >Foo</li >
82
82
</ul >
83
83
</section >
84
84
85
- <h4 >Finish</h4 >
85
+ <h3 >Finish</h3 >
86
86
<section >
87
87
<input id =" acceptTerms" name =" acceptTerms" type =" checkbox" class =" required" > <label for =" acceptTerms" >I agree with the Terms and Conditions.</label >
88
88
</section >
91
91
</section >
92
92
<section id =" advanced-form" >
93
93
<h2 class =" page-header" >Advanced Form Example</h2 >
94
-
94
+ <form id =" form-3" action =" #" >
95
+ <h3 >Account</h3 >
96
+ <fieldset >
97
+ <legend >Account Information</legend >
98
+
99
+ <label for =" userName" >User name *</label ><br >
100
+ <input id =" userName-2" name =" userName" type =" text" class =" required" ><br >
101
+ <label for =" password" >Password *</label ><br >
102
+ <input id =" password-2" name =" password" type =" text" class =" required" ><br >
103
+ <label for =" confirm" >Confirm Password *</label ><br >
104
+ <input id =" confirm-2" name =" confirm" type =" text" class =" required" ><br >
105
+ <p >(*) Mandatory</p >
106
+ </fieldset >
107
+
108
+ <h3 >Profile</h3 >
109
+ <fieldset >
110
+ <legend >Profile Information</legend >
111
+
112
+ <label for =" name" >First name *</label ><br >
113
+ <input id =" name-2" name =" name" type =" text" class =" required" ><br >
114
+ <label for =" surname" >Last name *</label ><br >
115
+ <input id =" surname-2" name =" surname" type =" text" class =" required" ><br >
116
+ <label for =" email" >Email *</label ><br >
117
+ <input id =" email-2" name =" email" type =" text" class =" required email" ><br >
118
+ <label for =" address" >Address</label ><br >
119
+ <input id =" address-2" name =" address" type =" text" ><br >
120
+ <label for =" age" >Age (Hint page will show up if age is less than 18) *</label ><br >
121
+ <input id =" age-2" name =" age" type =" text" class =" required number" ><br >
122
+ <p >(*) Mandatory</p >
123
+ </fieldset >
124
+
125
+ <h3 >Warning</h3 >
126
+ <fieldset >
127
+ <legend >You are to young</legend >
128
+
129
+ <p >Please go away ;-)</p >
130
+ </fieldset >
131
+
132
+ <h3 >Finish</h3 >
133
+ <fieldset >
134
+ <legend >Terms and Conditions</legend >
135
+
136
+ <input id =" acceptTerms-2" name =" acceptTerms" type =" checkbox" class =" required" > <label for =" acceptTerms" >I agree with the Terms and Conditions.</label >
137
+ </fieldset >
138
+ </form >
95
139
</section >
96
140
<section id =" manipulation" >
97
141
<h2 class =" page-header" >Dynamic Manipulation Example</h2 >
149
193
});
150
194
151
195
$ (" #wizard-2" ).steps ({
152
- headerTag: " h4 " ,
196
+ headerTag: " h3 " ,
153
197
bodyTag: " section" ,
154
198
transitionEffect: " slideLeft" ,
155
199
onStepChanging : function (event , currentIndex , newIndex )
167
211
alert (" Submitted!" );
168
212
}
169
213
});
214
+
215
+ $ (" #form-3" ).steps ({
216
+ headerTag: " h3" ,
217
+ bodyTag: " fieldset" ,
218
+ transitionEffect: " slideLeft" ,
219
+ onStepChanging : function (event , currentIndex , newIndex )
220
+ {
221
+ // Allways allow previous action even if the current form is not valid!
222
+ if (currentIndex > newIndex)
223
+ {
224
+ return true ;
225
+ }
226
+
227
+ // Forbid next action on "Warning" step if the user is to young
228
+ if (newIndex === 3 && Number ($ (" #age-2" ).val ()) < 18 )
229
+ {
230
+ return false ;
231
+ }
232
+
233
+ // Needed in some cases if the user went back (clean up)
234
+ if (currentIndex < newIndex)
235
+ {
236
+ // To remove error styles
237
+ $ (" #form-3 .body:eq(" + newIndex + " ) label.error" ).remove ();
238
+ $ (" #form-3 .body:eq(" + newIndex + " ) .error" ).removeClass (" error" );
239
+ }
240
+
241
+ $ (" #form-3" ).validate ().settings .ignore = " :disabled,:hidden" ;
242
+ return $ (" #form-3" ).valid ();
243
+ },
244
+ onStepChanged : function (event , currentIndex , priorIndex )
245
+ {
246
+ // Used to skip the "Warning" step if the user is old enough.
247
+ if (currentIndex === 2 && Number ($ (" #age-2" ).val ()) >= 18 )
248
+ {
249
+ $ (" #form-3" ).steps (" next" );
250
+ }
251
+
252
+ // Used to skip the "Warning" step if the user is old enough and wants to the previous step.
253
+ if (currentIndex === 2 && priorIndex === 3 )
254
+ {
255
+ $ (" #form-3" ).steps (" previous" );
256
+ }
257
+ },
258
+ onFinishing : function (event , currentIndex )
259
+ {
260
+ $ (" #form-3" ).validate ().settings .ignore = " :disabled" ;
261
+ return $ (" #form-3" ).valid ();
262
+ },
263
+ onFinished : function (event , currentIndex )
264
+ {
265
+ alert (" Submitted!" );
266
+ }
267
+ });
268
+
269
+ $ (" #form-3" ).validate ({
270
+ rules: {
271
+ confirm: {
272
+ equalTo: " #password-2"
273
+ }
274
+ }
275
+ });
170
276
});
171
277
</script >
172
278
}
0 commit comments