-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
166 lines (148 loc) · 5.32 KB
/
index.html
File metadata and controls
166 lines (148 loc) · 5.32 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
<!DOCTYPE html>
<html lang="en">
<head>
<script>
function checkForm(){
var nameBox = document.getElementById('name');
var emailBox = document.getElementById('email');
var phoneBox = document.getElementById('phone');
var dobBox = document.getElementById('gender');
var passwordBox = document.getElementById('password');
var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if(nameBox.value === ""){
nameBox.style.borderColor = 'red';
return false;
}else{
nameBox.style.borderColor = 'rgba(128, 128, 128, 0.521)';
}
if(emailBox.value === "" || !emailBox.value.match(validRegex)){
emailBox.style.borderColor = 'red';
return false;
}else{
emailBox.style.borderColor = 'rgba(128, 128, 128, 0.521)';
}
if(phoneBox.value === ""){
phoneBox.style.borderColor = 'red';
return false;
}else{
phoneBox.style.borderColor = 'rgba(128, 128, 128, 0.521)';
}
if(dobBox.value === ""){
dobBox.style.borderColor = 'red';
return false;
}else{
dobBox.style.borderColor = 'rgba(128, 128, 128, 0.521)';
}
if(passwordBox.value === ""){
passwordBox.style.borderColor = 'red';
return false;
}else{
passwordBox.style.borderColor = 'rgba(128, 128, 128, 0.521)';
}
alert("Form Submitted Successfully")
nameBox.value = "";
emailBox.value = "";
phoneBox.value = "";
passwordBox.value = "";
dobBox.value = "";
return true;
}
</script>
<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>Week 1 Task - Form</title>
</head>
<body>
<style>
#form input{
border-radius: 5px;
height: 40px;
width: 400px;
padding: 5px 10px;
font-size: 16px;
margin-top: 15px;
margin-bottom: 5px;
border: 1px solid rgba(128, 128, 128, 0.521);
}
#form select{
height: 45px;
width: 100%;
padding: 5px 10px;
font-size: 16px;
margin-top: 10px;
margin-bottom: 5px;
border-width: 1px;
border-radius: 5px;
border: 1px solid rgba(128, 128, 128, 0.521);
}
#form label{
font-size: 16px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}
#form #submit{
transition-duration: 300ms;
transition: ease-in-out;
border-radius: 5px;
height: 40px;
width: 100%;
padding: 5px 10px;
font-size: 16px;
background-color: red;
border: none;
color: white;
}
#form #submit:hover{
transition-duration: 300ms;
cursor: pointer;
border-radius: 5px;
height: 40px;
width: 100%;
padding: 5px 10px;
font-size: 16px;
background-color: blue;
border: none;
color: white;
}
.formclass{
height: 90vh;
display:flex;
align-items: center;
justify-content: center;
}
.form_div{
max-width: 600px;
width: 100%;
margin:auto;
height: 75vh;
margin: auto;
display:flex;
align-items: center;
justify-content: center;
background-color: white;
border-radius: 20px;
box-shadow: 0 0 10px -7px;
}
</style>
<section class ="formclass">
<div class="form_div">
<form id="form">
<label for="name">Name</label><br>
<input type="text" placeholder="Full Name" required id="name"><br><br>
<label for="email">Email</label><br>
<input type="email" placeholder="Email Address" required id="email"><br><br>
<label for="phone">Phone</label><br>
<input type="tel" placeholder="Phone Number" required id="phone"><br><br>
<label for="gender">Gender</label><br>
<select name="gender" required id="gender">
<option value="male">Male</option>
<option value="male">Female</option>
</select><br><br>
<label for="password">Password</label><br>
<input type="password" placeholder="Enter Password" required id="password"><br><br>
<input type="button" value="Submit" onclick="checkForm()" id="submit">
</form>
</div>
</section>
</body>
</html>