-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript3.html
More file actions
175 lines (136 loc) · 4.47 KB
/
Script3.html
File metadata and controls
175 lines (136 loc) · 4.47 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
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-color: rgb(90, 82, 82);
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.container{
background: linear-gradient(rgb(241, 175, 175) , rgb(202, 245, 202), rgb(153, 153, 240));
display: flex;
flex-direction: column;
text-align: center;
width: 500px;
height: 400px;
border-radius: 5px;
}
h1{
color: black;
align-items:center;
border-bottom:3px solid rgb(183, 171, 224) ;
padding: 20px;
}
.formstyle{
margin-top: 20px;
}
input{
margin-top: 20px;
border: none;
color:black;
outline: none;
background-color: transparent;
border-bottom: 1px solid blue;
width: 300px;
}
button{
margin-top: 20px;
border-radius: 20px;
padding: 3px 20px;
border:2px solid blue;
background-color: transparent;
color: black;
outline: blue;
}
#user{
color: red;
text-align: right;
display:block;
}
#pass{
color: red;
text-align: right;
display:block;
font-size: x-small;
font-weight: 50;
}
#forgot{
background-color: transparent;
text-decoration: none;
color:white;
}
</style>
</head>
<body>
<div class="container">
<h1>WELLCOME</h1>
<div class="formstyle">
<input type="text" id="username" placeholder="Username" oninput="username()" ><br>
<span id="user"></span>
<br>
<input type="password" id="passw" placeholder="Password" oninput="passw()"><br>
<span id="pass"></span>
<br>
<button>Login</button><br>
<a href="#" id="forgot">forgot password?</a>
</div>
</div>
<script>
// const passwordInput = document.getElementById('password');
// const passwordError = document.getElementById('password-error');
function username (){
const usernameInput = document.getElementById('username').value;
const userMessage = document.getElementById('user')
if(usernameInput.length>10){
userMessage.innerHTML = 'your username cannot be more than 12';
userMessage.style.color = "red"
}else if(usernameInput.length<5){
userMessage.innerHTML='username cannot be less than 5 😢';
userMessage.style.color ='red'
}
else{
userMessage.innerHTML='username is valid✔' ;
userMessage.style.color='green'
}
}
function passw(){
const passwordInput = document.getElementById('passw').value;
const passMessage = document.getElementById('pass');
const uppercase = /[A-Z]/.test(passwordInput);
const lowercase = /[a-z]/.test(passwordInput);
const number = /[0-9]/.test(passwordInput);
const specialcharacters = /[!@#$%^&*()_+=]/.test(passwordInput);
if(passwordInput.length>10){
passMessage.innerHTML = 'password cannot be more than 10😢';
passMessage.style.color ='red';
passMessage.style.fontSize='small';
}
else if(!uppercase){
passMessage.innerHTML = 'password must contain uppercase';
passMessage.style.color = 'red';
}else if(!specialcharacters){
passMessage.innerHTML = 'password must contain special char';
passMessage.style.color = 'red';
}else if(!lowercase){
passMessage.innerHTML = 'password must contain lowercase';
passMessage.style.color = 'red';
}else if(!number){
passMessage.innerHTML = 'password must contain number';
passMessage.style.color = 'red';
passMessage.style.fontSize='10px';
}
else{
passMessage.innerHTML ='valid';
passMessage.style.color = 'green';
passMessage.style.fontWeight='2em';
}
}
</script>
</body>
</html>