4949 <h2 class =" page-header" >Basic Form Example</h2 >
5050 <form id =" form-2" action =" #" >
5151 <div id =" wizard-2" >
52- <h4 >Account</h4 >
52+ <h3 >Account</h3 >
5353 <section >
5454 <label for =" userName" >User name *</label ><br >
5555 <input id =" userName" name =" userName" type =" text" class =" required" ><br >
6060 <p >(*) Mandatory</p >
6161 </section >
6262
63- <h4 >Profile</h4 >
63+ <h3 >Profile</h3 >
6464 <section >
6565 <label for =" name" >First name *</label ><br >
6666 <input id =" name" name =" name" type =" text" class =" required" ><br >
7373 <p >(*) Mandatory</p >
7474 </section >
7575
76- <h4 >Hints</h4 >
76+ <h3 >Hints</h3 >
7777 <section >
7878 <ul >
7979 <li >Foo</li >
8282 </ul >
8383 </section >
8484
85- <h4 >Finish</h4 >
85+ <h3 >Finish</h3 >
8686 <section >
8787 <input id =" acceptTerms" name =" acceptTerms" type =" checkbox" class =" required" > <label for =" acceptTerms" >I agree with the Terms and Conditions.</label >
8888 </section >
9191 </section >
9292 <section id =" advanced-form" >
9393 <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 >
95139 </section >
96140 <section id =" manipulation" >
97141 <h2 class =" page-header" >Dynamic Manipulation Example</h2 >
149193 });
150194
151195 $ (" #wizard-2" ).steps ({
152- headerTag: " h4 " ,
196+ headerTag: " h3 " ,
153197 bodyTag: " section" ,
154198 transitionEffect: " slideLeft" ,
155199 onStepChanging : function (event , currentIndex , newIndex )
167211 alert (" Submitted!" );
168212 }
169213 });
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+ });
170276 });
171277 </script >
172278}
0 commit comments