Registration page UI

 <!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Registration Page</title>

    <style>

        body {

            font-family: Arial, sans-serif;

        }

        .container {

            width: 50%;

            margin: 0 auto;

            padding: 20px;

            border: 1px solid #ccc;

            border-radius: 10px;

        }

        .form-group {

            margin-bottom: 15px;

        }

        .form-group label {

            display: block;

            margin-bottom: 5px;

        }

        .form-group input {

            width: 100%;

            padding: 8px;

            box-sizing: border-box;

        }

        .form-group .error {

            color: red;

            display: none;

        }

        .success {

            color: green;

        }

    </style>

</head>

<body>

    <div class="container">

        <h1>Register</h1>

        <form id="registrationForm">

            <div class="form-group">

                <label for="name">Customer Name</label>

                <input type="text" id="name" name="name" required>

                <div class="error" id="nameError">Customer Name must have alphabets only.</div>

            </div>

            <div class="form-group">

                <label for="email">Email</label>

                <input type="email" id="email" name="email" required>

                <div class="error" id="emailError">Email ID not valid.</div>

            </div>

            <div class="form-group">

                <label for="password">Password</label>

                <input type="password" id="password" name="password" required>

                <div class="error" id="passwordError">Password is not matching the criteria.</div>

            </div>

            <div class="form-group">

                <label for="address">Address</label>

                <input type="text" id="address" name="address" required>

            </div>

            <div class="form-group">

                <label for="contact">Contact Number</label>

                <input type="text" id="contact" name="contact" required>

                <div class="error" id="contactError">Contact Number must only contain numbers.</div>

            </div>

            <button type="button" onclick="register()">Register</button>

        </form>

        <div class="success" id="successMessage"></div>

    </div>


    <script>

        function register() {

            // Get form values

            const name = document.getElementById('name').value;

            const email = document.getElementById('email').value;

            const password = document.getElementById('password').value;

            const address = document.getElementById('address').value;

            const contact = document.getElementById('contact').value;


            // Validate form

            let valid = true;

            document.querySelectorAll('.error').forEach(error => error.style.display = 'none');


            if (!/^[A-Za-z]+$/.test(name)) {

                document.getElementById('nameError').style.display = 'block';

                valid = false;

            }

            if (!/@/.test(email)) {

                document.getElementById('emailError').style.display = 'block';

                valid = false;

            }

            if (!/(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*]).{5,}/.test(password)) {

                document.getElementById('passwordError').style.display = 'block';

                valid = false;

            }

            if (!/^\d+$/.test(contact)) {

                document.getElementById('contactError').style.display = 'block';

                valid = false;

            }


            if (valid) {

                // Simulate registration success

                const successMessage = `Registration successful. Customer Name: ${name}`;

                document.getElementById('successMessage').innerText = successMessage;

            }

        }

    </script>

</body>

</html>

Comments