forked from giraysam/viiny-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (78 loc) · 3.21 KB
/
index.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>Viiny-Form</title>
</head>
<body>
<div class="container mt-4">
<div class="form-wrapper">
<form action="#" class="needs-validation" novalidate>
<h4>Step-1</h4>
<div class="row">
<div class="col-12 col-md-6">
<div class="input-group mb-3">
<input type="text" required name="username" class="form-control" placeholder="username" />
</div>
</div>
<div class="col-12 col-md-6">
<div class="input-group mb-3">
<input type="text" required name="password" class="form-control" placeholder="password" />
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<button class="btn btn-primary btn-next">Next</button>
</div>
</div>
</form>
<form action="#" class="needs-validation" novalidate>
<h4>Step-2</h4>
<div class="row">
<div class="col-12 col-md-6">
<div class="input-group mb-3">
<input type="text" required name="firstname" class="form-control" placeholder="firstname" />
</div>
</div>
<div class="col-12 col-md-6">
<div class="input-group mb-3">
<input type="text" required name="lastname" class="form-control" placeholder="lastname" />
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<button class="btn btn-primary btn-prev">Prev</button>
<button class="btn btn-primary btn-next">Submit</button>
</div>
</div>
</form>
</div>
</div>
<script src="./src/index.js"></script>
<script type="text/javascript">
const vinnyForm = new ViinyForm('.form-wrapper', {
'nextButtonClass': 'btn-next',
'prevButtonClass': 'btn-prev',
'onNext': (index, form) => {
console.log("next: " + index);
console.log(form);
},
'onInvalid': (index, form) => {
const list = form.querySelectorAll(":invalid");
list.forEach(element => {
alert(`${element.getAttribute('name')} is Required`);
});
},
'onComplete': () => {
console.log("completed");
}
});
</script>
</body>
</html>