-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.html
65 lines (56 loc) · 1.77 KB
/
login.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
<!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>Login page</title>
</head>
<body>
<h1>Login page</h1>
<form action="" onsubmit="return bg()">
<input type="text" name="" id="name" placeholder="username"><br>
<p class="name" id="userError"></p>
<input type="password" name="" id="password" placeholder="password"><br>
<p class="name" id="passwordError"></p>
<input type="submit" value="submit">
</form>
</body>
<script>
let name = document.getElementById("name");
let password = document.getElementById("password");
let flag =1;
function bg(){
if(name.value == ""){
document.getElementById("userError").innerHTML = "Please fill the details";
flag = 0;
}
else if(name.value.length < 5){
document.getElementById("userError").innerHTML = "Username will 5 characters";
flag = 0;
}
else{
document.getElementById("userError").innerHTML = "";
flag = 1;
}
if(password.value == ""){
document.getElementById("passwordError").innerHTML = "Please fill the password";
flag = 0;
}
else if(password.value.length < 8){
document.getElementById("passwordError").innerHTML = "password should be 8 characters";
flag = 0;
}
else{
document.getElementById("passwordError").innerHTML = "";
flag = 1;
}
if(flag==1){
return true;
}
else{
return false;
}
}
</script>
</html>