Tuesday, June 21, 2022

Simple Login Using JavaScript

 A simple login that I wrote using JavaScript programming language.

 am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================


Want to support my channel?

GCash Account

Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support.




Program Listing

<!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>Simple Login Using JavaScript</title>

    <style>
        *,html {
            box-sizing: border-box;
            padding: 0;
            margin: 0;
        }
        main {
            display: flex;
            height: 100vh;
            width: 100vw;
            font-family: sans-serif;
        }
        .col {
            display: block;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
        }
        .col-1 {
            width: 65%;
            background: url("https://images.pexels.com/photos/807598/pexels-photo-807598.jpeg?cs=srgb&dl=pexels-sohail-nachiti-807598.jpg&fm=jpg&w=1920&h=1440");
            color: #fff;
            position: relative;
        }
        .col-1::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background: rgba(10, 44, 46, 0.8);
        }
        .col-2 {
            width: 35%;
            background-color: #fff;
        }
        .author {
            z-index: 1;
        }
        .author hr {
            width: 40px;
            margin: 30px auto;
        }
        .wrapper {
            width: 320px;
        }
        .logo {
            background-color: #154345;
            height: 60px;
            width: 60px;
            border-radius: 50%;
            margin: 0 auto 30px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 26px;
        }
        h3 {
            font-size: 25px;
            margin-bottom: 10px;
            text-transform: uppercase;
        }
        p {
            margin-bottom: 30px;
            font-size: 14px;
        }
        .block {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 6px;
            text-align: left;
        }
        input{
            width: 100%;
            padding: 10px;
            border: 1px solid #4AA68C;
            outline: none;
            border-radius: 3px;
        }
        button {
            background: #4AA68C;
            color: #fff;
            padding: 10px 20px;
            width: 100%;
            font-size: 15px;
            text-transform: uppercase;
            border-radius: 3px;
            border: 0;
        }
    </style>
</head>
<body>
    <main>
        <div class="col col-1">
            <div class="author">
                <h1>Simple Login Using JavaScript</h1>
                <hr>
                <h2>Jake R. Pomperada, MAED-IT, MIT</h2>
            </div>
        </div>
        <div class="col col-2">
            <div class="wrapper">
                <div class="logo">
                    <span>&#128274;</span>
                </div>

                <h3>~ Login ~</h3>
                <p>Please enter your username and password below to access your account.</p>

                <form action="" method="post">
                    <div class="block">
                        <label for="">Username</label>
                        <input type="text" id="txtUsername">
                    </div>
                    <div class="block">
                        <label for="">Password</label>
                        <input type="password" id="txtPassword">
                    </div>
                    <button type="submit">Submit</button>
                </form>
            </div>
        </div>
    </main>

    <script>
        document.querySelector('form').onsubmit  = (e) => {
            e.preventDefault()

            let username  = "123", password  = "123",
                inputUser = document.querySelector('#txtUsername'),
                inputPass = document.querySelector('#txtPassword'),
                form      = document.querySelector("form")

            if (inputUser.value != username || inputPass.value != password) {
                alert("Username and Password do not match. Please try again.")
            }
            if (inputUser.value == username && inputPass.value == password) {
                alert("Success! You're currently logged in now.")
            }

            form.reset();
            inputUser.focus();
        }
    </script>
</body>
</html>

No comments:

Post a Comment