-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-wizard.js
49 lines (49 loc) · 1.32 KB
/
form-wizard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$(function() {
'use strict'
$('#wizard1').steps({
headerTag: 'h3',
bodyTag: 'section',
autoFocus: true,
titleTemplate: '<span class="number">#index#<\/span> <span class="title">#title#<\/span>'
});
$('#wizard2').steps({
headerTag: 'h3',
bodyTag: 'section',
autoFocus: true,
titleTemplate: '<span class="number">#index#<\/span> <span class="title">#title#<\/span>',
onStepChanging: function(event, currentIndex, newIndex) {
if (currentIndex < newIndex) {
// Step 1 form validation
if (currentIndex === 0) {
var fname = $('#firstname').parsley();
var lname = $('#lastname').parsley();
if (fname.isValid() && lname.isValid()) {
return true;
} else {
fname.validate();
lname.validate();
}
}
// Step 2 form validation
if (currentIndex === 1) {
var email = $('#email').parsley();
if (email.isValid()) {
return true;
} else {
email.validate();
}
}
// Always allow step back to the previous step even if the current step is not valid.
} else {
return true;
}
}
});
$('#wizard3').steps({
headerTag: 'h3',
bodyTag: 'section',
autoFocus: true,
titleTemplate: '<span class="number">#index#<\/span> <span class="title">#title#<\/span>',
stepsOrientation: 1
});
});