-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginpage.html
69 lines (48 loc) · 1.71 KB
/
loginpage.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
<!DOCTYPE html>
<html>
<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>Login Page</title>
<style>
#main-content{
width:50%;
margin:auto;
}
#but{
margin-left: 130px;
}
body{background-color: skyblue;}
</style>
</head>
<body>
<div id="main-content">
<h1 style="margin-left:30px">Welcome User</h1>
<label for="user">Username:</label>
<input type="text" id="user" placeholder="Username" required />
<br/> <br/>
<label for="pass">Password:</label>
<input type="password" id="pass" placeholder="password" required />
<br><br>
<div id="but"><button type="button" id="btn" value="Login" onclick="validate()">Login</button></div>
</div>
<script>
function validate(){
let u = document.getElementById("user").value;
let p = document.getElementById("pass").value;
let us = /[A-Za-z0-9]/;
let pa = /[a-z]{8}/;
if(us.test(u) && pa.test(p)) {
alert("Welcome to Web World");
document.write(Date(),u);
document.body.bgColor="yellow";
}
else
{
alert("Invalid username or password.Please only write alphanumeric characters");
}
};
</script>
</body>
</html>