-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.html
185 lines (162 loc) · 4.67 KB
/
signup.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
<!DOCTYPE html>
<html lang="en">
<head>
<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>Sign Up</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css"
/>
<style>
body {
padding: 10px 50px;
background-image: url(tree.jpg);
background-size: 110%;
}
.container {
background-color: cornsilk;
width: 500px;
margin-left: 300px;
padding-left: 55px;
padding-top: 30px;
padding-bottom: 30px;
border-radius: 16px;
}
.formdesign {
font-size: 20px;
}
.formdesign input {
width: 80%;
padding: 12px 20px;
border: 1px solid darkblue;
margin: 14px;
border-radius: 4px;
font-size: 15px;
}
.formerror {
color: red;
}
.button {
border-radius: 9px;
width: 100px;
height: 50px;
font-size: 25px;
margin: 22px 20px;
}
p {
text-align: center;
padding-top: 15px;
font-size: 15px;
}
.para-2 {
text-align: center;
color: black;
font-size: 20px;
}
.para-2 a {
color: dodgerblue;
}
</style>
</head>
<body>
<div class="container">
<form
aciton="/myaction.php"
name="myForm"
onsubmit="return validateForm()"
method="post"
>
<div class="formdesign" id="name">
Name: <input type="text" name="firstname" required /><b
><span class="formerror"> </span
></b>
</div>
<div class="formdesign" id="email">
Email: <input type="email" name="pemail" required /><b
><span class="formerror"> </span
></b>
</div>
<div class="formdesign" id="phone">
Phone: <input type="phone" name="enterphone" required /><b
><span class="formerror"></span
></b>
</div>
<div class="formdesign" id="pass">
Password: <input type="password" name="firstpass" required /><b
><span class="formerror"></span
></b>
</div>
<div class="formdesign" id="cpass">
Confirm Password:
<input type="password" name="confirmpass" required /><b
><span class="formerror"></span
></b>
</div>
<input class="button" type="submit" value="Submit" />
</form>
<p>
By clicking the Sign Up button, you agree to our <br />
<a href="#">Terms of Service</a> and <a href="#">Privacy Policy</a>
</p>
<p class="para-2">
Already have an account? <a href="login.html">Login Here</a>
</p>
</div>
</body>
<script>
function clearErrors() {
errors = document.getElementsByClassName("formerror");
for (let item of errors) {
item.innerHTML = "";
}
}
function seterror(id, error) {
//shows error message
element = document.getElementById(id);
element.getElementsByClassName("formerror")[0].innerHTML = error;
}
//form validation
function validateForm() {
var returnval = true;
clearErrors();
//username validation
var name = document.forms["myForm"]["firstname"].value;
if (name.length < 5) {
seterror("name", "*Length of name is too short");
returnval = false;
}
//if field is empty -
if (name.length == 0) {
seterror("name", "*Length of name cannot be zero!");
returnval = false;
}
//email address validation
var email = document.forms["myForm"]["pemail"].value;
if (email.length > 15) {
seterror("email", "*Email length is too long");
returnval = false;
}
//phone no validation
var phone = document.forms["myForm"]["enterphone"].value;
if (phone.length != 10) {
seterror("phone", "*Phone number should be of 10 digits!");
returnval = false;
}
//user password validation
var password = document.forms["myForm"]["firstpass"].value;
if (password.length < 6) {
seterror("pass", "*Password should be atleast 6 characters long!");
returnval = false;
}
//confirming password entered by user
var cpassword = document.forms["myForm"]["confirmpass"].value;
if (cpassword != password) {
seterror("cpass", "*Password and Confirm password should match!");
returnval = false;
}
return returnval;
}
</script>
</html>