-
Notifications
You must be signed in to change notification settings - Fork 0
/
Submitform.html
238 lines (211 loc) · 5.41 KB
/
Submitform.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Add icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script>
function validateForm() {
var fullname = document.forms["myForm"]["usrnm"].value;
var email = document.forms["myForm"]["email"].value;
var password = document.forms["myForm"]["psw"].value;
var phone = document.forms["myForm"]["phone"].value;
var gender = document.forms["myForm"]["gender"].value;
if (fullname == "" || email == "" || password == "" || phone == "" || gender == "") {
alert("Please fill out all required fields.");
return false;
}
// Validate email format
var emailRegex = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/;
if (!emailRegex.test(email)) {
alert("Please enter a valid email address.");
return false;
}
// Validate password length
if (password.length < 4) {
alert("Password must be at least 4 characters long.");
return false;
}
// Validate phone number format
var phoneRegex = /^\d{11}$/;
if (!phoneRegex.test(phone)) {
alert("Please enter a valid 11-digit phone number.");
return false;
}
// Validate gender selection
if (!gender) {
alert("Please select a valid gender.");
return false;
}
if (fullname != "" && emailRegex.test(email) && password.length >= 4 && phoneRegex.test(phone) && gender != "") {
alert("Submission successful!");
return true;
form.reset();
}
}
</script>
<style>
body {font-family: Arial, Helvetica, sans-serif;
background-color: black;}
* {box-sizing: border-box;}
.input-container {
display: -ms-flexbox; /* IE10 */
display: flex;
width: 100%;
margin-bottom: 15px;
}
.icon {
padding: 10px;
background: dodgerblue;
color: white;
min-width: 50px;
text-align: center;
}
.input-field {
width: 100%;
padding: 10px;
outline: none;
}
.input-field:focus, .btn:hover {
outline: none;
border-color: dodgerblue;
box-shadow: 0 0 20px dodgerblue;
}
/* Set a style for the submit button */
.btn {
background-color: dodgerblue;
color: white;
padding: 15px 20px;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.btn:hover {
opacity: 1;
}
input[type=radio] {
display: none;
}
label.radio {
position: relative;
display: inline-block;
padding-top: 4px;
margin-right: 20px;
text-indent: 30px;
overflow: visible;
cursor: pointer;
padding-bottom:2px;
}
label.radio:before {
content: "";
position: absolute;
top: 2px;
left: 0;
width: 20px;
height: 20px;
border-radius: 50%;
background: dodgerblue;
}
label.radio:after {
content: "";
position: absolute;
width: 9px;
height: 4px;
top: 8px;
left: 4px;
border: 3px solid #fff;
border-top: none;
border-right: none;
transform: rotate(-45deg);
opacity: 0;
}
input[type=radio]:checked + label:after {
opacity: 1;
}
.gender{
font-size:20px;
}
h2{
text-align:center;
}
fieldset{
background-color: #0e0c0c;
max-width: 500px;
height: 480px;
margin: auto;
margin-top: 100px;
padding-left: 50px;
padding-right: 50px;
border-radius: 20px;
border-style: 20px groove;
border-color: red navy magenta purple;
animation: glow 4s ease-in-out infinite; /* add an animation with a 2-second duration that loops infinitely */
color: linear-gradient(45deg, navy, purple, red, yellow, hotpink, green, brown, cyan, magenta );
z-index: -1;
}
@keyframes glow {
0% {
border-color: red;
}
25% {
border-color: navy;
}
50% {
border-color: magenta;
}
75% {
border-color: purple;
}
100% {
border-color: red;
}
}
fieldset:hover {
box-shadow: 0 0 50px 50px navy;
}
h2, label.radio {
color: white;
}
.input-field {
width: 100%;
padding: 10px;
outline: none;
font-size: 20px;
}
</style>
</head>
<body>
<fieldset>
<form name="myForm" action="" onsubmit="return validateForm()" style="max-width:500px;margin:auto">
<h2>BIO-DATA</h2>
<hr>
<div class="input-container">
<i class="fa fa-user icon"></i>
<input class="input-field" type="text" placeholder="Fullname" name="usrnm" required>
</div>
<div class="input-container">
<i class="fa fa-envelope icon"></i>
<input class="input-field" type="Email" placeholder="Email" name="email" required>
</div>
<div class="input-container">
<i class="fa fa-key icon"></i>
<input class="input-field" type="password" placeholder="Password" name="psw" required>
</div>
<div class="input-container">
<i class="fa fa-phone icon"></i>
<input class="input-field" type="phone" placeholder="Phone number" name="phone"required>
</div>
<hr>
<div class="gender">
<input type="radio" value="none" id="male" name="gender" />
<label for="male" class="radio">Male</label>
<input type="radio" value="none" id="female" name="gender"/>
<label for="female" class="radio">Female</label>
</div>
<hr>
<button type="submit" class="btn">SUBMIT</button>
</form>
</fieldset>
</body>
</html>