forked from RAI-ADF/RAI_Task_4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistrationForm.php
More file actions
218 lines (167 loc) · 5.3 KB
/
registrationForm.php
File metadata and controls
218 lines (167 loc) · 5.3 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.datepick.css">
<script type="text/javascript" src="jquery.plugin.js"></script>
<script type="text/javascript" src="jquery.datepick.js"></script>
<body>
<style>
body{
background-color: #009688;
}
input {
width: 250px;
height: 30px;
background: transparent;
border: 1px solid rgba(255,255,255,0.6);
border-radius: 2px;
color: #fff;
font-family: 'Exo', sans-serif;
font-size: 16px;
font-weight: 400;
padding: 4px;
}
select {
width: 250px;
height: 30px;
background: transparent;
border: 1px solid rgba(255,255,255,0.6);
border-radius: 2px;
color: #909EA3;
font-family: 'Exo', sans-serif;
font-size: 16px;
font-weight: 400;
padding: 4px;
}
button{
width: 250px;
height: 30px;
background: transparent;
border: 1px solid rgba(255,255,255,0.6);
border-radius: 2px;
color: #fff;
font-family: 'Exo', sans-serif;
font-size: 16px;
font-weight: 400;
padding: 4px;
}
.title{
width: 350px;
height: 50px;
background: transparent;
color: #fff;
font-family: 'Exo', sans-serif;
font-size: 35px;
font-weight: 400;
padding: 4px;
}
</style>
<?php
//session_start();
//echo "Hi " . $_SESSION["username"] . ".<br>";
?>
<div align="center">
<form method="post" onsubmit="return validation()" name="form" id="form">
<div class="title">Registration Form</div>
<input type="text" name="username" required placeholder="Username">
<br><br>
<input type="password" name="password" required placeholder="Password">
<br><br>
<input type="password" name="password1" required placeholder="Re-type Password">
<br><br>
<input type="text" name="name" required placeholder="Name">
<br><br>
<input type="text" name="email" required placeholder="Email">
<br><br>
<select name="category" id="category" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);" required >
<option value="">Place of Birth</option>
<option value="Jawa Barat">Jawa Barat</option>
<option value="Jawa Timur">Jawa Timur</option>
<option value="Sumatra">Sumatra</option>
</select>
<script type="text/javascript" language="JavaScript">
document.write('<select name="subcategory" id="subcategory"><option value="">Select City</option></select>')
</script>
<br><br>
<input name="datepicker" id="datepicker" type="text" required placeholder="Date of Birth">
<br><br>
<input type="submit" value="Submit">
<button type="reset" value="Reset">Reset</button>
</form>
</div>
</body>
<script type="text/javascript">
$('#datepicker').datepick({dateFormat: 'yyyy-mm-dd'});
function validateEmail(){
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
var input = document.forms["form"]["email"].value;
if(input == mailformat)
{
document.form.email.focus();
return true;
}
else
{
alert("You have entered an invalid email address!");
document.form.email.focus();
return false;
}
}
function validatePassword() {
var x = document.forms["form"]["password"].value;
var y = document.forms["form"]["password1"].value;
if (x == y) {
return true;
}else{
alert("You have entered a different password!");
document.form.password.focus();
return false;
}
}
function validate(){
var validation = true;
validation &= validateEmail();
validation &= validatePassword();
return validation;
}
function validation(){
var validation = validate();
if(validation = true){
document.getElementsByTagName("form")[0].setAttribute("action", "insert.php");
}else{
document.getElementsByTagName("form")[0].setAttribute("action", "registrationForm.php");
}
}
function dropdownlist(listindex)
{
//document.form.subcategory.options.length = 0;
switch (listindex)
{
case "Jawa Barat" :
document.form.subcategory.options[0]=new Option("Select City","");
document.form.subcategory.options[1]=new Option("Bandung","Bandung");
document.form.subcategory.options[2]=new Option("Cirebon","Cirebon");
document.form.subcategory.options[3]=new Option("Tasikmalaya","Tasikmalaya");
document.form.subcategory.options[4]=new Option("Bekasi","Bekasi");
document.form.subcategory.options[5]=new Option("Depok","Depok");
break;
case "Jawa Timur" :
document.form.subcategory.options[0]=new Option("Select City","");
document.form.subcategory.options[1]=new Option("Malang","Malang");
document.form.subcategory.options[2]=new Option("Surabaya","Surabaya");
document.form.subcategory.options[3]=new Option("Kediri","Kediri");
document.form.subcategory.options[4]=new Option("Banyuwangi","Banyuwangi");
break;
case "Sumatra" :
document.form.subcategory.options[0]=new Option("Select City","");
document.form.subcategory.options[1]=new Option("Medan","Medan");
document.form.subcategory.options[2]=new Option("Palembang","Palembang");
document.form.subcategory.options[3]=new Option("Lampung","Lampung");
document.form.subcategory.options[4]=new Option("Aceh","Aceh");
document.form.subcategory.options[5]=new Option("Padang","Padang");
break;
}
return true;
}
</script>
</html>