-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
178 lines (164 loc) · 8.29 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!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">
<title>Form Validation</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class="main">
<!-- sign up -->
<form method="POST" class="form" id="sign-up">
<h3 class="heading">Sign up</h3>
<p class="desc">Register to receive offers from us right now!</p>
<div class="row" style="width: 800px;">
<div class="col">
<div class="form-group">
<label for="fullname" class="form-label">Fullname</label>
<input id="fullname" name="fullname" type="text" rules="required"
placeholder="Nhập tên của bạn" class="form-control">
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="username" class="form-label">Username</label>
<input id="username" name="username" type="text" rules="required|min:3|max:10"
placeholder="Chọn tên tài khoản của bạn" class="form-control">
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="password" class="form-label">Password</label>
<input id="password" name="password" type="password" rules="required|min:3"
placeholder="Nhập mật khẩu" class="form-control">
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="password_confirmation" class="form-label">Confirm password</label>
<input id="password_confirmation" name="password_confirmation"
rules="required|confirm:#password" placeholder="Nhập lại mật khẩu" type="password"
class="form-control">
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="phone" class="form-label">Phone</label>
<input id="phone" name="phone" type="number" rules="required|min:10|max:10"
placeholder="Nhập số điện thoại" class="form-control">
<span class="form-message"></span>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="avatar" class="form-label">Avatar</label>
<input id="avatar" name="avatar" type="file" rules="required" class="form-radio-control">
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="email" class="form-label">Email</label>
<input id="email" name="email" type="text" rules="required|email"
placeholder="Nhập email đăng ký" class="form-control">
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="city" class="form-label">City</label>
<select id="city" rules="required" name="city" class="form-control">
<option value="">-- Chọn thành phố --</option>
<option value="ha noi">Hà Nội</option>
<option value="ho chi minh">Hồ Chí Minh</option>
<option value="thanh hoa">Thanh Hóa</option>
<option value="nghe an">Nghệ An</option>
<option value="dong nai">Đồng Nai</option>
<option value="binh duong">Bình Dương</option>
<option value="hai phong">Hải Phòng</option>
<option value="an giang">An Giang</option>
<option value="hai duong">Hải Dương</option>
<option value="hue">Huế</option>
</select>
<span class="form-message"></span>
</div>
<div class="form-group">
<label class="form-label">Gender</label>
<div class="form-radio-control">
<div>
<input name="gender" type="radio" rules="checkone:gender" value="nam"
class="form-radio">Nam
</div>
<div>
<input name="gender" type="radio" rules="checkone:gender" value="nu"
class="form-radio">Nữ
</div>
<div>
<input name="gender" type="radio" rules="checkone:gender" value="khac"
class="form-radio">Khác
</div>
</div>
<span class="form-message"></span>
</div>
<div class="form-group">
<label for="address" class="form-label">Address</label>
<input id="address" name="address" type="number" rules="required"
placeholder="Nhập địa chỉ của bạn" class="form-control">
<span class="form-message"></span>
</div>
</div>
</div>
<button class="form-submit" type="submit" name="register-submit">Sign up</button>
<p class="desc">Already have an account? <a href="./login.html">Sign in</a></p>
</form>
</div>
<!-- script js -->
<script src="./js/validator.js"></script>
<script>
document.querySelectorAll("button").addEventListener("click", function(event){
if (!confirm("Are you sure?")) {
event.preventDefault();
return;
}
}
Validator({
form: '#form-1',
formGroupSelector: '.form-group',
errorSelector: '.form-message',
rules: [
Validator.isRequired('#fullname', `Nhập họ tên của bạn!`),
Validator.isRequired('#email'),
Validator.isEmail('#email', `Địa chỉ email không chính xác!`),
Validator.isRequired('#password'),
Validator.minLength('#password', 6, `Mật khẩu tối thiểu 6 ký tự!`),
Validator.isRequired('#password_confirmation'),
Validator.isConfirmed('#password_confirmation', '#password', `Nhập lại mật khẩu không khớp!`),
],
onSubmit: function (data) {
alert(JSON.stringify(data));
}
});
Validator({
form: '#form-2',
formGroupSelector: '.form-group',
errorSelector: '.form-message',
rules: [
Validator.isRequired('#avatar', `Vui lòng chọn ảnh đại diện!`),
Validator.isRequired('#province'),
Validator.isRequired('input[name="gender"]'),
Validator.isRequired('input[name="social"]', `Vui lòng chọn tối thiểu 1 lựa chọn`),
],
onSubmit: function (data) {
alert(JSON.stringify(data));
}
});
Validator({
form: '#form-3',
formGroupSelector: '.form-group',
errorSelector: '.form-message',
rules: [
Validator.isRequired('#email'),
Validator.isEmail('#email', `Địa chỉ email không chính xác!`),
Validator.isRequired('#password'),
],
onSubmit: function (data) {
alert(JSON.stringify(data));
}
});
</script>
</body>
</html>