Create a LogIn form for website with HTML, CSS, and JAVASCRIPT




 Title: Seamless Access: Creating a Login Form with HTML, CSS, and JavaScript

Introduction:

A login form is an essential component of any website that requires user authentication. In this tutorial, we will guide you through the process of creating a user-friendly and secure login form using HTML, CSS, and JavaScript. By leveraging these technologies, we will ensure a seamless and intuitive login experience for your website visitors.

Key Steps:

1. HTML Structure:- We will start by creating the HTML structure for the login form. This will involve creating input fields for the username and password, along with a submit button. Additionally, we can include other elements such as a "Remember Me" checkbox and a "Forgot Password" link, depending on your specific requirements.

2. CSS Styling:- Next, we will enhance the visual appeal of the login form using CSS. You can customize the form's appearance by adding colors, fonts, and layouts that align with your website's design. CSS allows you to create a visually pleasing and consistent login form that matches your brand identity.

3. Form Validation with JavaScript:- To ensure data integrity and security, we will implement form validation using JavaScript. JavaScript will validate the user's inputs and ensure that the required fields are filled correctly. You can add conditions to check for the presence of a valid username and password format before allowing the form submission.

4. Handling Form Submission:- Once the form is validated, we will define JavaScript functions to handle the form submission. This involves capturing the input values, validating them against a database or server-side authentication, and granting access to the user if the credentials are valid. In case of invalid credentials, appropriate error messages can be displayed.

5. Remember Me Functionality:- If desired, we can incorporate a "Remember Me" feature using JavaScript. This allows users to save their login credentials for future visits, eliminating the need to enter them repeatedly. We can store the login details securely in browser cookies or implement a more secure authentication method, such as JSON Web Tokens (JWT).

6. Password Recovery:- In case users forget their passwords, we can include a "Forgot Password" functionality. This can be achieved by implementing a password recovery system that sends a reset link or generates a temporary password to the user's registered email address. JavaScript can handle the necessary logic to initiate the password recovery process.

Conclusion:

By following these steps, you can create a functional and secure login form for your website using HTML, CSS, and JavaScript. The form will provide users with a seamless and intuitive login experience while ensuring data integrity and security. Additionally, you can customize the form's appearance to match your website's design and incorporate additional features such as "Remember Me" functionality and password recovery.



HTML CODE


<div class="main">
    <div class="cart">
        <h4 class="title">Log In!</h4>
        <form>
            <div class="field">
                <svg class="input-icon" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
            <path d="M207.8 20.73c-93.45 18.32-168.7 93.66-187 187.1c-27.64 140.9 68.65 266.2 199
                  .1 285.1c19.01 2.88836.17-12.26 36.17-31.49l.0001-.6631c0-15.74-11.44-28.88-26.
                 84-31.24c-84.35-12.98-149.2-86.13-149.2-174.2c0-102.9 88.61-185.5 193.4-175.4c91
                .54 8.869 158.6 91.25 158.6 183.2l0 16.16c0 22.09-17.94 40.05-4040.05s-40.01-17.96
                -40.01-40.05v-120.1c0-8.847-7.161-16.02-16.01-16.02l-31.98 .0036c-7.299 0-13.2 4.992
                -15.12 11.68c-24.85-12.15-54.24-16.38-86.06-5.106c-38.75 13.73-68.12 48.91-73.72 89.
                64c-9.483 69.01 43.81 128 110.9 128c26.44 0 50.43-9.544 69.59-24.88c24 31.3 65.23 48.
                69 109.4 37.49C465.2 369.3 496 324.1495.1 277.2V256.3C495.1 107.1 361.2-9.332 207.8
                20.73zM239.1 304.3c-26.47 0-48-21.56-48-48.05s21.53-48.05 48-48.05s48 21.56 48 48.05S
                266.5 304.3 239.1 304.3z">
            </path>
                </svg>
                <input type="email" name="logemail" class="input-field" placeholder="Email" id="logemail"
                    autocomplete="off">
            </div>
            <div class="field">
                <svg class="input-icon" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
           <path
             d="M80 192V144C80 64.47 144.5 0 224 0C303.5 0 368 64.47 368 144V192H384C419.3 192 448
                220.7 448 256V448C448 483.3419.3 512 384 512H64C28.65 512 0 483.3 0 448V256C0 220.
                7 28.65 192 64 192H80zM144 192H304V144C304 99.82 268.2 64224 64C179.8 64 144 99.82
            144 144V192z"></path>
                </svg>
                <input type="password" name="logpass" class="input-field" placeholder="Password" id="logpass"
                    autocomplete="off">
            </div>
            <button class="btn" type="submit">Login</button>
            <a href="#" class="btn-link">Forgot Your Password?</a>
        </form>
    </div>
</div>

CSS CODE


        * {
            margin: 0;
            padding: 0;
        }

        .main {
            width: 100%;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .cart {
            width: 300px;
            padding: 5rem 3rem;
            text-align: center;
            background: #2a2b38;
            border-radius: 10px;
        }

        .field {
            margin-top: 1rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 1em;
            background: #1f2029;
            border-radius: 4px;
            padding: 1em 1em;
        }

        .input-icon {
            height: 1em;
            width: 1em;
            fill: #ffeba7;
        }

        .input-field {
            background: none;
            border: none;
            outline: none;
            width: 100%;
            color: #d3d3d3;
        }

        .title {
            margin-bottom: 1rem;
            font-size: 1.5rem;
            color: #f5f5f5;
            font-weight: 500;
            font-family: Arial, Helvetica, sans-serif;
        }

        .btn {
            margin: 1rem;
            border: none;
            border-radius: 4px;
            font-weight: bold;
            font-size: .8em;
            text-transform: uppercase;
            padding: .6em 1.2em;
            background: #ffeba7;
            transition: all .3s ease-in-out;
            cursor: pointer;
        }

        .btn:hover {
            background: #1f2029;
            color: #ffeba7;
        }

        .btn-link {
            color: #eee;
            display: block;
            font-size: .75em;
            transition: color .3s ease-out;
            font-family: Arial, Helvetica, sans-serif;
            margin-top: 20px;
        }

        .btn-link:hover {
            color: #ffeba7;
        }

        .field input:focus::placeholder {
            opacity: 0;
            transition: opacity .3s;
        }

Comments