How to create customer feedback survey form using html

This modern survey form features a clean, minimalist design with a responsive layout that works seamlessly on both mobile and desktop devices. It includes all required form fields—such as text inputs, radio buttons, checkboxes, and a dropdown—with proper validation to ensure users complete mandatory fields before submission. The form provides visual feedback with error messages and a success notification, all without page reloads, creating a smooth and user-friendly experience.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Customer Feedback Survey</title> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet"> </head> <body> <div class="container"> <h1>Customer Feedback Survey</h1> <p>We value your opinion. Please take a few minutes to share your experience with us.</p> <form id="surveyForm"> <div class="form-group"> <label for="fullName">Full Name*</label> <input type="text" id="fullName" name="fullName" placeholder="Enter your full name"> <div class="error" id="nameError">Please enter your name</div> </div> <div class="form-group"> <label for="email">Email Address*</label> <input type="email" id="email" name="email" placeholder="Enter your email"> <div class="error" id="emailError">Please enter a valid email address</div> </div> <div class="form-group"> <label for="age">Age</label> <input type="number" id="age" name="age" min="13" max="120" placeholder="Enter your age"> </div> <div class="form-group"> <label>Gender</label> <div class="radio-group"> <div class="radio-option"> <input type="radio" id="male" name="gender" value="Male"> <label for="male">Male</label> </div> <div class="radio-option"> <input type="radio" id="female" name="gender" value="Female"> <label for="female">Female</label> </div> <div class="radio-option"> <input type="radio" id="other" name="gender" value="Other"> <label for="other">Other</label> </div> </div> </div> <div class="form-group"> <label for="satisfaction">How satisfied are you with our service?*</label> <select id="satisfaction" name="satisfaction"> <option value="">Select your satisfaction level</option> <option value="Very Satisfied">Very Satisfied</option> <option value="Satisfied">Satisfied</option> <option value="Neutral">Neutral</option> <option value="Dissatisfied">Dissatisfied</option> <option value="Very Dissatisfied">Very Dissatisfied</option> </select> <div class="error" id="satisfactionError">Please select your satisfaction level</div> </div> <div class="form-group"> <label>What features would you like to see improved? (Select all that apply)</label> <div class="checkbox-group"> <div class="checkbox-option"> <input type="checkbox" id="speed" name="improvements" value="Speed"> <label for="speed">Speed</label> </div> <div class="checkbox-option"> <input type="checkbox" id="design" name="improvements" value="Design"> <label for="design">Design</label> </div> <div class="checkbox-option"> <input type="checkbox" id="features" name="improvements" value="Features"> <label for="features">Features</label> </div> <div class="checkbox-option"> <input type="checkbox" id="support" name="improvements" value="Support"> <label for="support">Support</label> </div> </div> </div> <div class="form-group"> <label for="comments">Any comments or suggestions?</label> <textarea id="comments" name="comments" placeholder="Your feedback helps us improve..."></textarea> </div> <button type="submit" id="submitBtn">Submit Feedback</button> </form> <div class="success-message" id="successMessage"> <h3>Thank you for your feedback!</h3> <p>We appreciate you taking the time to help us improve our services.</p> </div> </div> </body> </html>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you have to make a file with a .css extension.


 :root {
            --primary-color: #4a6bff;
            --secondary-color: #f5f7ff;
            --text-color: #333;
            --light-gray: #f0f2f5;
            --border-radius: 8px;
            --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Poppins', sans-serif;
            line-height: 1.6;
            color: var(--text-color);
            background-color: var(--light-gray);
            padding: 20px;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 30px;
            background-color: white;
            border-radius: var(--border-radius);
            box-shadow: var(--box-shadow);
        }

        h1 {
            text-align: center;
            margin-bottom: 30px;
            font-weight: 600;
            color: var(--primary-color);
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
        }

        input[type="text"],
        input[type="email"],
        input[type="number"],
        select,
        textarea {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: var(--border-radius);
            font-family: inherit;
            font-size: 16px;
            transition: border-color 0.3s;
        }

        input[type="text"]:focus,
        input[type="email"]:focus,
        input[type="number"]:focus,
        select:focus,
        textarea:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(74, 107, 255, 0.2);
        }

        textarea {
            min-height: 120px;
            resize: vertical;
        }

        .radio-group, .checkbox-group {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin-top: 10px;
        }

        .radio-option, .checkbox-option {
            display: flex;
            align-items: center;
        }

        .radio-option input, .checkbox-option input {
            margin-right: 8px;
        }

        .range-slider {
            width: 100%;
            margin-top: 10px;
        }

        .range-labels {
            display: flex;
            justify-content: space-between;
            margin-top: 5px;
            font-size: 14px;
            color: #666;
        }

        button {
            display: block;
            width: 100%;
            padding: 14px;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: var(--border-radius);
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s;
            margin-top: 30px;
        }

        button:hover {
            background-color: #3a5bef;
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(74, 107, 255, 0.2);
        }

        .success-message {
            display: none;
            text-align: center;
            padding: 20px;
            background-color: #e8f5e9;
            color: #2e7d32;
            border-radius: var(--border-radius);
            margin-top: 20px;
        }

        .error {
            color: #d32f2f;
            font-size: 14px;
            margin-top: 5px;
            display: none;
        }

        @media (max-width: 600px) {
            .container {
                padding: 20px;
            }

            .radio-group, .checkbox-group {
                flex-direction: column;
                gap: 10px;
            }
        }
JavaScript makes the page work functionally. At last, create a JavaScript file with the name of script.js, and remember that you've got to make a file with a .js extension.


document.getElementById('surveyForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            // Reset errors
            document.querySelectorAll('.error').forEach(el => el.style.display = 'none');
            
            // Validate form
            let isValid = true;
            
            // Name validation
            const name = document.getElementById('fullName').value.trim();
            if (!name) {
                document.getElementById('nameError').style.display = 'block';
                isValid = false;
            }
            
            // Email validation
            const email = document.getElementById('email').value.trim();
            const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
            if (!email || !emailRegex.test(email)) {
                document.getElementById('emailError').style.display = 'block';
                isValid = false;
            }
            
            // Satisfaction validation
            const satisfaction = document.getElementById('satisfaction').value;
            if (!satisfaction) {
                document.getElementById('satisfactionError').style.display = 'block';
                isValid = false;
            }
            
            if (isValid) {
                // Form is valid - show success message
                document.getElementById('surveyForm').style.display = 'none';
                document.getElementById('successMessage').style.display = 'block';
                
                // In a real app, you would send the data to a server here
                // const formData = new FormData(this);
                // fetch('/submit-survey', { method: 'POST', body: formData })
                //     .then(response => response.json())
                //     .then(data => {
                //         document.getElementById('surveyForm').style.display = 'none';
                //         document.getElementById('successMessage').style.display = 'block';
                //     });
            }
        });
We hope you Like this Post Thanks for coming Here

Thank you
Learning robo team

Post a Comment

Thank you
Learning robo team

Post a Comment (0)

Previous Post Next Post
Learning Robo says...
code copied