-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
176 lines (160 loc) · 6.79 KB
/
index.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 lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hover Placeholder With Validation</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
</head>
<bod <div class="container">
<h1>REGISTER</h1>
<form id="registration_form">
<div>
<input type="text" id="form_fname" name="" required="">
<span class="error_form" id="fname_error_message"></span>
<label>
First Name
</label>
</div>
<div>
<input type="text" id="form_sname" name="" required="">
<span class="error_form" id="sname_error_message"></span>
<label>
Second Name
</label>
</div>
<div>
<input type="email" id="form_email" name="" required="">
<span class="error_form" id="email_error_message"></span>
<label>Email id</label>
</div>
<div>
<input type="password" id="form_password" name="" required="">
<span class="error_form" id="password_error_message"></span>
<label>Password</label>
</div>
<div>
<input type="password" id="form_retype_password" name="" required="">
<span class="error_form" id="retype_password_error_message"></span>
<label>Re-Enter Password</label>
</div>
<input type="submit" value="Register" name="">
</form>
<p style="padding-top: 25px; text-align: center; color:rgb(66, 133, 244) ; "><strong>Created By Muhammad Shahid</strong></p>
</div>
<script type="text/javascript">
$(function() {
$("#fname_error_message").hide();
$("#sname_error_message").hide();
$("#email_error_message").hide();
$("#password_error_message").hide();
$("#retype_password_error_message").hide();
var error_fname = false;
var error_sname = false;
var error_email = false;
var error_password = false;
var error_retype_password = false;
$("#form_fname").focusout(function() {
check_fname();
});
$("#form_sname").focusout(function() {
check_sname();
});
$("#form_email").focusout(function() {
check_email();
});
$("#form_password").focusout(function() {
check_password();
});
$("#form_retype_password").focusout(function() {
check_retype_password();
});
function check_fname() {
var pattern = /^[a-zA-Z]*$/;
var fname = $("#form_fname").val();
if (pattern.test(fname) && fname !== '') {
$("#fname_error_message").hide();
$("#form_fname").css("border-bottom", "2px solid #34F458");
} else {
$("#fname_error_message").html("Should contain only Characters");
$("#fname_error_message").show();
$("#form_fname").css("border-bottom", "2px solid #F90A0A");
error_fname = true;
}
}
function check_sname() {
var pattern = /^[a-zA-Z]*$/;
var sname = $("#form_sname").val()
if (pattern.test(sname) && sname !== '') {
$("#sname_error_message").hide();
$("#form_sname").css("border-bottom", "2px solid #34F458");
} else {
$("#sname_error_message").html("Should contain only Characters");
$("#sname_error_message").show();
$("#form_sname").css("border-bottom", "2px solid #F90A0A");
error_fname = true;
}
}
function check_password() {
var password_length = $("#form_password").val().length;
if (password_length < 8) {
$("#password_error_message").html("Atleast 8 Characters");
$("#password_error_message").show();
$("#form_password").css("border-bottom", "2px solid #F90A0A");
error_password = true;
} else {
$("#password_error_message").hide();
$("#form_password").css("border-bottom", "2px solid #34F458");
}
}
function check_retype_password() {
var password = $("#form_password").val();
var retype_password = $("#form_retype_password").val();
if (password !== retype_password) {
$("#retype_password_error_message").html("Passwords Did not Matched");
$("#retype_password_error_message").show();
$("#form_retype_password").css("border-bottom", "2px solid #F90A0A");
error_retype_password = true;
} else {
$("#retype_password_error_message").hide();
$("#form_retype_password").css("border-bottom", "2px solid #34F458");
}
}
function check_email() {
var pattern = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var email = $("#form_email").val();
if (pattern.test(email) && email !== '') {
$("#email_error_message").hide();
$("#form_email").css("border-bottom", "2px solid #34F458");
} else {
$("#email_error_message").html("Invalid Email");
$("#email_error_message").show();
$("#form_email").css("border-bottom", "2px solid #F90A0A");
error_email = true;
}
}
$("#registration_form").submit(function() {
error_fname = false;
error_sname = false;
error_email = false;
error_password = false;
error_retype_password = false;
check_fname();
check_sname();
check_email();
check_password();
check_retype_password();
if (error_fname === false && error_sname === false && error_email === false && error_password === false && error_retype_password === false) {
alert("Registration Successfull");
return true;
} else {
alert("Please Fill the form Correctly");
return false;
}
});
});
</script>
</body>
</html>