A simple login form using JavaScript programming language. I hope you will find my work useful.

I 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 in 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 Form Using JavaScript</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #01C3FF;
            font-family: sans-serif;
        }
        form,
        .message {
            padding: 30px;
            border-radius: 3px;
            background: #fff;
        }
        h2, h4 {
            margin: 5px 0;
            color: #1F1A19;
            text-align: center;
            line-height: 1.2;
        }
        input {
            display: block;
            padding: 8px 3px;
            outline: none;
            font-size: 12px;
            border-top: 0;
            border-right: 0;
            border-left: 0;
            border-bottom: 2px solid #01C3FF;
            border-radius: 0;
            margin-top: 10px;
            width: 100%;
            color: #888;
        }
        input:first-of-type {
            margin-top: 15px;
        }
        .btn {
            padding: 8px ;
            text-align: center;
            display: block;
            width: 100%;
            cursor: pointer;
            border: none;
            background: #01C3FF;
            color: #fff;
            margin-top: 10px;
            border-radius: 3px;
            text-decoration: none;
        }
        button:hover {
            opacity: 0.9;
        }
        .hide {
            display: none;
        }
        #messageDetails {
            margin-bottom: 20px;
            text-align: center;
        }
    </style>
</head>
<body>
    <form action="" id="frmLogin">
        <hr>
        <h2>Simple Login Form<br>Using JavaScript</h2>
        <h4>Jake R. Pomperada, MAED-IT, MIT</h4>
        <hr>

        <input type="text" name="txtUsername" id="txtUsername" placeholder="Enter your username" required>
        <input type="password" name="txtPassword" id="txtPassword" placeholder="Enter your password" required>
        <button type="submit" class="btn">Login</button>
    </form>

    <div class="message hide">
        <p id="messageDetails"></p>
        <a href="" class="btn">Reset</a>
    </div>

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

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

            if (inputUser != username || inputPass != password) {
                document.querySelector('#messageDetails').innerHTML = "Username and Password do not match.<br>Please try again."
            }
            if (inputUser == username && inputPass == password) {
                document.querySelector('#messageDetails').innerHTML = "Success!<br>You're currently logged in now."
            }

            document.querySelector('#frmLogin').classList.add("hide")
            document.querySelector('.message').classList.remove("hide")
        }
    </script>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *