-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.html
289 lines (272 loc) · 8.15 KB
/
registration.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<!DOCTYPE html>
<html>
<head>
<title> FORM</title>
<style>
#fin{
background-color: rgb(73, 143, 40);
color: white;
justify-content: center;
margin-left: -20%;
font-size: 25px;
}
body {
background: linear-gradient(white,rgb(90, 171, 238),white);
display: block;
height: 220vh;
justify-content: center;
align-items: center;
padding: 2px;
}
.title{
font-family: sans-serif;
font-size: 30px;
font-weight: bold;
text-align: center;
color: rgb(141, 54, 241);
font-style: italic;
text-decoration: underline;
background-color: azure;
border-radius: 2px solid black;
}
#op {
color: rgb(6, 6, 48);
font-weight: bold;
width:200px;
display: inline-block;
}
.f{
width: 85%;
background-color:azure;
padding: 15px 35px;
border-radius: 10px;
margin:auto;
margin-top: 2%;
border-radius: 2px solid rgb(109, 109, 233);
}
#se{
width: 90%;
background-color:azure;
border-radius: 10px;
margin:auto;
border-radius: 2px solid rgb(109, 109, 233);
}
.x{
height: 15px;
width: 300px;
margin: 12px 0 12px 0;
}
#leg{
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
text-align: center;
font-style: italic;
background-color:azure;
border: 1px solid black;
}
#subleg{
font-family: sans-serif;
font-size: 18px;
font-weight: bold;
font-style: italic;
color:blue;
}
#x{
height: 15px;
width: 300px;
margin: 12px 0 12px 0;
}
#mainform{
max-width: 1200px;
max-height: 2000px;
width: 70%;
background:linear-gradient(rgb(242, 250,170),rgb(245, 240, 240),rgb(242, 250, 170));
margin:auto;
padding: 10px 30px;
border: 5px solid darkslateblue;
}
</style>
</head>
<body>
<div id="mainform">
<fieldset class="f" style="border: 2px solid rgb(33, 206, 85);">
<div class="title">REGISTRATION FORM</div>
</fieldset>
<br/>
<form method="POST" onsubmit='formValidator()' action="success.html">
<fieldset class="f" style="border: 2px solid red;">
<label id="op">First Name : </label>
<input id="firstname" class="x" type="text" placeholder="First Name" required="required">
<br>
<label id="op">Last Name : </label>
<input id="lastname" class="x" type="text" placeholder="Last Name">
<br>
<label id="op">Date of Birth : </label>
<input class="x" type="date" name="date" required="required">
<br>
<label id="op" >Gender : </label>
<input type="radio" name="gender1"> Male
<input type="radio" name="gender2"> Female
<input type="radio" name="gender3"> others
<br>
<label id="op">Mobile Number : </label>
<input class="x" id="mobilenumber" type="text" name="num" maxlength="10" required>
<br>
<label id="op">Address: </label>
<textarea type="textarea" id="addr" class="x" placeholder="Enter the address here" required></textarea>
<br>
<label id="op">Email : </label>
<input class="x" id="email" type="email" name="email" required><br />
<br>
<label id="op">State : </label>
<input class="x" type="text" name="state" required>
<br>
<label id="op">City : </label>
<input type="text" name="city" required>
</fieldset><br/>
<br/>
<br/>
<div style="margin-left: 390px;">
<input id="fin" type="submit" value=" Submit ">
<input id="fin" style="background-color:rgb(238, 48, 23); margin-left: 40px; color: white" type="reset" value=" Reset " >
</div>
</form>
</div>
<script type='text/javascript'>
function formValidator()
{
// Make quick references to our fields
var firstname = document.getElementById('firstname');
var lastname = document.getElementById('lastname');
var email = document.getElementById('email');
var pass = document.getElementById('pass');
var addr = document.getElementById('addr');
var mobileno = document.getElementById('mobileno');
// Check each input in the order that it appears in the form!
if(notEmpty(firstname, "can not be null"))
{
if(isAlphabet(firstname, "Please enter only letters for your Firstname"))
{
if(lengthRestriction(firstname, 6))
{
if(isAlphabet(lastname, "Please enter only letters for your Lastname"))
{
if(emailValidator(email, "Please enter a valid email address"))
{
if(lengthRestriction(pass, 6))
{
if(isAlphanumeric(pass, "please enter Numbers and Letters Only for password"))
{
if(notEmpty(addr, "please enter the address"))
{
if(isNumeric(mobileno, "Please enter a valid mobileno"))
{
if(lengthRestriction1(mobileno, 10 , 10))
{
return true;
}
}
}
}
}
}
}
}
}
}
return false;
}
function notEmpty(elem, helperMsg)
{
if(elem.value.length == 0)
{
alert(helperMsg);
elem.focus(); // set the focus to this input
return false;
}
return true;
}
function isNumeric(elem, helperMsg)
{
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphabet(elem, helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphanumeric(elem, helperMsg)
{
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
return true;
}
else
{
alert(helperMsg);
elem.focus();
return false;
}
}
function lengthRestriction(elem, min)
{
var uInput = elem.value;
if(uInput.length >= min){
return true;
}
else
{
alert("Please enter minimum " +min+ " characters");
elem.focus();
return false;
}
}
function emailValidator(elem, helperMsg)
{ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.match(emailExp))
{
return true;
}
else{
alert(helperMsg);
elem.focus();
return false;
}
}
function lengthRestriction1(elem, min, max)
{
var uInput = elem.value;
if(uInput.length >= min && uInput.length <= max)
{
return true;
}
else {
alert("Please enter 10 numbers only");
elem.focus();
return false;
}
}
</script>
</body>
</html>