-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegistration_Form.html
194 lines (183 loc) · 6.96 KB
/
Registration_Form.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<html>
<head>
<title>Registration form.com</title>
<style>
body{
background-color: rgba(247, 239, 239, 0.884);
}
</style>
</head>
<body>
<div class="container">
<h1><b>REGISTRATION FORM</b></h1>
<form name="registration" class="registartion-form" onsubmit="return formValidation()">
<table>
<tr>
<td><label for="userid">USER ID</label></td>
<td><input type="userid" name="userid" id="userid" placeholder="userid"></td>
</tr>
<tr>
<td><label for="name">NAME:</label></td>
<td><input type="text" name="name" id="name" placeholder="name"></td>
</tr>
<tr>
<td><label for="email">EMAIL:</label></td>
<td><input type="text" name="email" id="email" placeholder="email"></td>
</tr>
<tr>
<td><label for="password">PASSWORD:</label></td>
<td><input type="password" name="password" id="password" placeholder="password"></td>
</tr>
<tr>
<td><label for="phoneNumber">PHONE NUMBER:</label></td>
<td><input type="number" name="phoneNumber" id="phoneNumber"></td>
</tr>
<tr>
<td><label for="gender">GENDER:</label></td>
<td>Male <input type="radio" name="gender" value="male">
Female <input type="radio" name="gender" value="female">
Other <input type="radio" name="gender" value="other"></td>
</tr>
<tr>
<td><label for="Country">COUNTRY</label></td>
<td>
<select name="Country" id="country">
<option value="">Select Country</option>
<option value="Africa">Africa</option>
<option value="America">America</option>
<option value="Bangalore">Bangalore</option>
<option value="China">China</option>
<option value="Dubai">Dubai</option>
<option value="Germany">Germany</option>
<option value="India">India</option>
<option value="Japan">Japan</option>
<option value="Russia">Russia</option>
</select>
</td>
</tr>
<tr>
<td><label for="zipcode">ZIP CODE:</label></td>
<td><input type="number" name="zipcode" id="zipcode"></td>
</tr>
<tr>
<td><label for="language">LANGUAGE:</label></td>
<td>English <input type="checkbox" name="English" value="English">
Hindi <input type="checkbox" name="Non English" value="non english">
</tr>
<tr>
<td><label for="about">ABOUT:</label></td>
<td><textarea name="about" id="about" placeholder="Write about yourself..."></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" class="submit" value="SUBMIT" /></td>
</tr>
</table>
</form>
</div>
<style>
* {
margin: 0
}
.container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
}
.container h1 {
color: rgb(0, 0, 0);
font-family: sans-serif;
margin: 20px;
}
.registartion-form {
display: flex;
justify-content: center;
align-items: center;
width: 600px;
color: rgb(15, 6, 6);
font-size: 120px;
font-family: sans-serif;
background-color: hsla(0, 91%, 87%, 0.742);
padding: 1px;
}
.registartion-form input,
.registartion-form select,
.registartion-form textarea {
border: none;
padding: 5px;
margin-top: 10px;
font-family: sans-serif;
}
.registartion-form input:focus,
.registartion-form textarea:focus {
box-shadow: 10px 10px 10px rgb(228, 228, 228), -3px -3px 10px rgb(224, 224, 224);
}
.registartion-form .submit {
width: 100%;
padding: 8px 0;
font-size: 20px;
color: rgb(12, 4, 4);
background-color: #746363;
border-radius: 5px;
}
.registartion-form .submit:hover {
box-shadow: 3px 3px 6px rgb(255, 214, 176);
}
</style>
<script>
// Select all input elements for varification
const name = document.getElementById("name");
const email = document.getElementById("email");
const password = document.getElementById("password");
const phoneNumber = document.getElementById("phoneNumber");
const gender = document.registration;
const language = document.getElementById("language");
const zipcode = document.getElementById("zipcode");
// function for form validation
function formValidation() {
// checking name length
if (name.value.length < 2 || name.value.length > 20) {
alert("Name length should be more than 2 and less than 21");
name.focus();
return false;
}
// checking email
if (email.value.match(/^\w+([\.-]?\w+)w+([\.-]?\w+)*(\.\w{2,3})+$/)) {
alert("Please enter a valid email!");
email.focus();
return false;
}
// checking password
if (!password.value.match(/^.{5,15}$/)) {
alert("Password length must be between 5-15 characters!");
password.focus();
return false;
}
// checking phone number
if (!phoneNumber.value.match(/^[1-9][0-9]{9}$/)) {
alert("Phone number must be 10 characters long number and first digit can't be 0!");
phoneNumber.focus();
return false;
}
// checking gender
if (gender.gender.value === "") {
alert("Please select your gender!");
return false;
}
// checking language
if (language.value === "") {
alert("Please select your language!")
return false;
}
// checking zip code
if (!zipcode.value.match(/^[0-9]{6}$/)) {
alert("Zip code must be 6 characters long number!");
zipcode.focus();
return false;
}
return true;
}
</script>
</body>
</html>