lab6
user_1845816280
html
3 years ago
3.1 kB
3
Indexable
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Login Page</title> <style> .login-page { width: 360px; padding: 8% 0 0; margin: auto; } .form { position: relative; z-index: 1; background: #ffffff; max-width: 360px; margin: 0 auto 100px; padding: 45px; text-align: center; } .button { text-transform: uppercase; outline: 0; background: #4caf50; width: 100%; border: 0; padding: 15px; color: #ffffff; font-size: 14px; transition: all 0.3 ease; } .container { position: relative; z-index: 1; max-width: 300px; margin: 0 auto; } .inputField { outline: 0; background: #f2f2f2; width: 100%; border: 0; margin: 0 0 15px; padding: 15px; box-sizing: border-box; font-size: 14px; } body { background: green; } #actionField { padding: 20px; display: none; } </style> </head> <body> <div class="login-page"> <div class="form"> <form class="login-form"> <input class="inputField" type="text" placeholder="username" id="usernameField"/> <input class="inputField" type="password" placeholder="password" id="passwordField"/> <button class="button" onclick="checkInput()">login</button> <p class="message"> Not registered? <a href="#">Create an account</a> </p> </form> <div id="actionField"></div> </div> </div> <script> function checkInput() { var username = document.getElementById("usernameField").value; var password = document.getElementById("passwordField").value; if (username == "" && password== "") { response("user name and password fields cannot be empty"); } else if (username == "") { response("user name field cannot be empty"); } else if (password == "") { response("password field cannot be empty"); } else if (username == "admin" && password == "123") { loginSuccess("login success"); } else { response("login failed"); } } function response(text) { document.getElementById("actionField").innerText = text; document.getElementById("actionField").style.display = "block"; document.getElementById("actionField").style.color = "red"; } function loginSuccess(text){ document.getElementById("actionField").innerText = text; document.getElementById("actionField").style.display = "block"; document.getElementById("actionField").style.color = "green"; } </script> </body> </html>
Editor is loading...