-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleTable.html
176 lines (155 loc) · 4.23 KB
/
SimpleTable.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
<!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;
}
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 {
border: 2px solid grey;
}
/* 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;
color: white;
}
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;
}
h2{
text-align:center;
}
</style>
</head>
<body>
<form name="myForm" action="" onsubmit="return validateForm()" style="max-width:500px;margin:auto">
<h2 style="color: white;">Sign-up</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" required/>
<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>
</body>
</html>