Prechádzať zdrojové kódy

dz js2 creat to join menu

mmertalagoz 4 rokov pred
commit
3eba1178b6
3 zmenil súbory, kde vykonal 129 pridanie a 0 odobranie
  1. 48 0
      homework2 js/css/style.css
  2. 29 0
      homework2 js/index.html
  3. 52 0
      homework2 js/script.js

+ 48 - 0
homework2 js/css/style.css

@@ -0,0 +1,48 @@
+form {
+	width: 600px;
+	margin: 200px auto;
+}
+div {
+	width: 100%;
+	margin: 15px auto;
+}
+label {
+	display: block;
+	padding: 20px;
+	font-size: 25px;
+}
+input {
+	width: 96%;
+	padding: 10px;
+	border: 1px solid #797979;
+	font-size: 20px;
+	margin-left: 20px;
+	border-radius: 3px;
+}
+button {
+	margin: 20px;
+	padding: 20px;
+	width: 100px;
+	border: none;
+	outline: none;
+	cursor: pointer;
+	border-radius: 5px;
+	font-size: 20px;
+	font-weight: bold;
+	color: whitesmoke;
+	background-color: darkblue;
+	text-align: center;
+}
+span {
+	display: block;
+	margin-left: 20px;
+	color: red;
+	font-style: italic;
+}
+.formbox {
+	display: flex;
+	align-items: center;
+	width: 800px;
+	height: 600px;
+	background-color: rgba(157, 240, 255, 0.747);
+}

+ 29 - 0
homework2 js/index.html

@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="stylesheet" href="./css/style.css">
+    <title>DzJsJoinMenu</title>
+</head>
+<body>
+    
+
+    <div class="formbox">
+    <form action="https://a-level.com.ua" method="POST">
+        <div>
+            <label for="username">Имя</label>
+            <input type="text" name="username" placeholder="Имя с латинскими буквами">
+            <span></span>
+        </div>
+        <div>
+            <label for="password">Пароль</label>
+            <input type="password" name="password" placeholder="Пароль с латинскими буквами">
+            <span></span>
+        </div>
+        <button id="log-in">log-in</button>
+    </form>
+</div>
+</body>
+</html>
+<script src="./script.js"></script>

+ 52 - 0
homework2 js/script.js

@@ -0,0 +1,52 @@
+window.onload = () =>{
+    this.sessionStorage.setItem("username", "admin");
+    this.sessionStorage.setItem("password", "qwerty");
+}
+var input = document.getElementsByTagName('input');
+var login = document.getElementById('log-in');
+var form = document.querySelector('form');
+form.onsubmit = ()=>{return false}
+
+login.onclick = ()=>{
+    if ((input[0].value != "") && (input[1].value != "")) 
+    {
+        if ((input[0].value == sessionStorage.getItem("username")) && (input[1].value == sessionStorage.getItem("password"))) 
+        {
+            form.onsubmit = ()=>{return 1}
+        }
+        else
+        {
+            if ((input[0].value != sessionStorage.getItem("username"))) 
+            {
+                input[0].nextElementSibling.textContent = "Имя не правильно";
+                 setTimeout(()=>{
+                     input[0].nextElementSibling.textContent = "";
+                 }, 2000);
+            }
+            if ((input[1].value != sessionStorage.getItem("password"))) 
+            {
+                input[1].nextElementSibling.textContent = "Пароль не правильно";
+                 setTimeout(()=>{
+                     input[1].nextElementSibling.textContent = "";
+                 }, 2000);
+            }
+        }
+    }
+    else
+    {
+        if (input[0].value == "")
+        {
+            input[0].nextElementSibling.textContent = "Username is empty";
+            setTimeout(()=>{
+                input[0].nextElementSibling.textContent = "";
+            }, 2000);
+        }
+        if (input[1].value == "")
+        {
+            input[1].nextElementSibling.textContent = "Password is empty";
+            setTimeout(()=>{
+                input[1].nextElementSibling.textContent = "";
+            }, 2000);
+        }
+    }
+}