Dmv registration form - html css js source code

This code includes:

A modern gradient background with glassmorphism effect

Soft shadows and rounded corners for all elements

Clean Poppins font throughout

Two-step form with smooth sliding transition

Client-side validation for required fields

Visual indicators for required fields and validation errors

Progress bar and step indicators

Responsive design that works on different screen sizes

Color selection with "Other" option that shows a text field when selected

Proper navigation between steps with Previous/Next buttons

The form validates all required fields and shows appropriate error messages when validation fails. The design follows modern UI trends with subtle animations and visual feedback.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>DMV Registration Form</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>DMV Vehicle Registration</h1> <div class="progress-bar"> <div class="progress" id="progress"></div> </div> <div class="step-indicator"> <div class="step active" id="step1-indicator">1</div> <div class="step" id="step2-indicator">2</div> </div> <div class="form-container" id="form-container"> <!-- Step 1: Personal Information --> <div class="form-step" id="step1"> <div class="form-group"> <label for="firstName" class="required">First Name</label> <input type="text" id="firstName" placeholder="Enter your first name" required> </div> <div class="form-group"> <label for="lastName" class="required">Last Name</label> <input type="text" id="lastName" placeholder="Enter your last name" required> </div> <div class="form-group"> <label for="email" class="required">Email</label> <input type="email" id="email" placeholder="Enter your email" required> <div class="error-message" id="email-error">Please enter a valid email address</div> </div> <div class="form-group"> <label for="phone" class="required">Phone</label> <input type="tel" id="phone" placeholder="Enter your phone number" required> <div class="error-message" id="phone-error">Please enter a valid phone number</div> </div> <div class="form-group"> <label for="street" class="required">Street Address</label> <input type="text" id="street" placeholder="Enter your street address" required> </div> <div class="form-group"> <label for="city" class="required">City</label> <input type="text" id="city" placeholder="Enter your city" required> </div> <div class="form-group"> <label for="state" class="required">State</label> <select id="state" required> <option value="">Select State</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> </select> </div> <div class="form-group"> <label for="zip" class="required">ZIP Code</label> <input type="text" id="zip" placeholder="Enter your ZIP code" required> </div> <div class="form-group"> <label for="country" class="required">Country</label> <select id="country" required> <option value="US" selected>United States</option> <option value="CA">Canada</option> <option value="MX">Mexico</option> </select> </div> <div class="buttons"> <button class="btn-next" id="nextBtn">Next</button> </div> </div> <!-- Step 2: Vehicle Information --> <div class="form-step" id="step2"> <div class="form-group"> <label for="vehicleName" class="required">Vehicle Name</label> <input type="text" id="vehicleName" placeholder="Enter vehicle name" required> <div class="error-message" id="vehicleName-error">Please enter vehicle name</div> </div> <div class="form-group"> <label for="vehicleModel" class="required">Vehicle Model</label> <input type="text" id="vehicleModel" placeholder="Enter vehicle model" required> <div class="error-message" id="vehicleModel-error">Please enter vehicle model</div> </div> <div class="form-group"> <label for="registrationNumber" class="required">Vehicle Registration #</label> <input type="text" id="registrationNumber" placeholder="Enter registration number" required> <div class="error-message" id="registrationNumber-error">Please enter registration number</div> </div> <div class="form-group"> <label for="chassisNumber" class="required">Chassis #</label> <input type="text" id="chassisNumber" placeholder="Enter chassis number" required> <div class="error-message" id="chassisNumber-error">Please enter chassis number</div> </div> <div class="form-group"> <label class="required">Vehicle Color</label> <div class="color-options" required> <label class="color-option"><input type="checkbox" name="color" value="White"> White</label> <label class="color-option"><input type="checkbox" name="color" value="Black"> Black</label> <label class="color-option"><input type="checkbox" name="color" value="Red"> Red</label> <label class="color-option"><input type="checkbox" name="color" value="Green"> Green</label> <label class="color-option"><input type="checkbox" name="color" value="Yellow"> Yellow</label> <label class="color-option"><input type="checkbox" name="color" value="Orange"> Orange</label> <label class="color-option"><input type="checkbox" name="color" value="Blue"> Blue</label> <label class="color-option"><input type="checkbox" name="color" value="Other"> Other</label> </div> <input type="text" id="otherColor" placeholder="Specify other color" style="margin-top: 10px; display: none;"> <div class="error-message" id="color-error">Please select at least one color</div> </div> <div class="form-group"> <label for="fabricationYear" class="required">Fabrication Year</label> <input type="number" id="fabricationYear" min="1900" max="2023" placeholder="Enter fabrication year" required> <div class="error-message" id="fabricationYear-error">Please enter a valid year (1900-2023)</div> </div> <div class="form-group"> <label for="mileage" class="required">Current Mileage</label> <input type="number" id="mileage" min="0" placeholder="Enter current mileage" required> <div class="error-message" id="mileage-error">Please enter valid mileage</div> </div> <div class="form-group"> <label for="ignitionKey" class="required">Ignition Key #</label> <input type="text" id="ignitionKey" placeholder="Enter ignition key number" required> <div class="error-message" id="ignitionKey-error">Please enter ignition key number</div> </div> <div class="form-group"> <label for="doorKey" class="required">Door Key #</label> <input type="text" id="doorKey" placeholder="Enter door key number" required> <div class="error-message" id="doorKey-error">Please enter door key number</div> </div> <div class="form-group"> <label for="dealerName" class="required">Dealer Name</label> <input type="text" id="dealerName" placeholder="Enter dealer name" required> <div class="error-message" id="dealerName-error">Please enter dealer name</div> </div> <div class="form-group"> <label for="dealerCity" class="required">Dealer City</label> <input type="text" id="dealerCity" placeholder="Enter dealer city" required> <div class="error-message" id="dealerCity-error">Please enter dealer city</div> </div> <div class="buttons"> <button class="btn-prev" id="prevBtn">Previous</button> <button class="btn-submit" id="submitBtn">Register</button> </div> </div> </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.


* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Poppins', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
            width: 100%;
            max-width: 800px;
            padding: 30px;
            position: relative;
            overflow: hidden;
        }

        .container::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
            transform: rotate(45deg);
            z-index: -1;
        }

        h1 {
            text-align: center;
            margin-bottom: 30px;
            color: #2c3e50;
            font-weight: 600;
        }

        .form-container {
            display: flex;
            width: 200%;
            transition: transform 0.5s ease-in-out;
        }

        .form-step {
            width: 50%;
            padding: 0 30px;
        }

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

        label {
            display: block;
            margin-bottom: 8px;
            color: #2c3e50;
            font-weight: 500;
        }

        .required::after {
            content: '*';
            color: #e74c3c;
            margin-left: 4px;
        }

        input, select {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.8);
            transition: all 0.3s;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }

        input:focus, select:focus {
            outline: none;
            border-color: #3498db;
            box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
        }

        .error {
            border-color: #e74c3c !important;
        }

        .error-message {
            color: #e74c3c;
            font-size: 12px;
            margin-top: 5px;
            display: none;
        }

        .color-options {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 10px;
        }

        .color-option {
            display: flex;
            align-items: center;
        }

        .color-option input[type="checkbox"] {
            width: auto;
            margin-right: 8px;
        }

        .buttons {
            display: flex;
            justify-content: space-between;
            margin-top: 30px;
        }

        button {
            padding: 12px 25px;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .btn-next {
            background: #3498db;
            color: white;
            margin-left: auto;
        }

        .btn-prev {
            background: #95a5a6;
            color: white;
        }

        .btn-submit {
            background: #2ecc71;
            color: white;
        }

        button:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }

        .progress-bar {
            height: 5px;
            background: #ecf0f1;
            border-radius: 5px;
            margin-bottom: 30px;
            overflow: hidden;
        }

        .progress {
            height: 100%;
            width: 50%;
            background: linear-gradient(90deg, #3498db, #2ecc71);
            transition: width 0.5s ease;
        }

        .step-indicator {
            display: flex;
            justify-content: center;
            margin-bottom: 20px;
        }

        .step {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: #bdc3c7;
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 0 10px;
            font-weight: 600;
        }

        .step.active {
            background: #3498db;
        }

        .step.completed {
            background: #2ecc71;
        }
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.addEventListener('DOMContentLoaded', function() {
            const formContainer = document.getElementById('form-container');
            const nextBtn = document.getElementById('nextBtn');
            const prevBtn = document.getElementById('prevBtn');
            const submitBtn = document.getElementById('submitBtn');
            const progress = document.getElementById('progress');
            const step1Indicator = document.getElementById('step1-indicator');
            const step2Indicator = document.getElementById('step2-indicator');
            
            // Color other option toggle
            const colorCheckboxes = document.querySelectorAll('input[name="color"]');
            const otherColorInput = document.getElementById('otherColor');
            
            colorCheckboxes.forEach(checkbox => {
                checkbox.addEventListener('change', function() {
                    if (this.value === 'Other' && this.checked) {
                        otherColorInput.style.display = 'block';
                    } else if (this.value === 'Other' && !this.checked) {
                        otherColorInput.style.display = 'none';
                    }
                });
            });
            
            // Form navigation
            nextBtn.addEventListener('click', function(e) {
                e.preventDefault();
                if (validateStep1()) {
                    formContainer.style.transform = 'translateX(-50%)';
                    progress.style.width = '100%';
                    step1Indicator.classList.remove('active');
                    step1Indicator.classList.add('completed');
                    step2Indicator.classList.add('active');
                }
            });
            
            prevBtn.addEventListener('click', function(e) {
                e.preventDefault();
                formContainer.style.transform = 'translateX(0)';
                progress.style.width = '50%';
                step2Indicator.classList.remove('active');
                step1Indicator.classList.add('active');
                step1Indicator.classList.remove('completed');
            });
            
            // Form validation
            function validateStep1() {
                let isValid = true;
                const email = document.getElementById('email');
                const phone = document.getElementById('phone');
                
                // Email validation
                if (!email.value || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.value)) {
                    email.classList.add('error');
                    document.getElementById('email-error').style.display = 'block';
                    isValid = false;
                } else {
                    email.classList.remove('error');
                    document.getElementById('email-error').style.display = 'none';
                }
                
                // Phone validation (simple version)
                if (!phone.value || !/^[\d\s\-\(\)]{10,}$/.test(phone.value)) {
                    phone.classList.add('error');
                    document.getElementById('phone-error').style.display = 'block';
                    isValid = false;
                } else {
                    phone.classList.remove('error');
                    document.getElementById('phone-error').style.display = 'none';
                }
                
                return isValid;
            }
            
            function validateStep2() {
                let isValid = true;
                const requiredFields = [
                    'vehicleName', 'vehicleModel', 'registrationNumber', 
                    'chassisNumber', 'fabricationYear', 'mileage',
                    'ignitionKey', 'doorKey', 'dealerName', 'dealerCity'
                ];
                
                // Check required fields
                requiredFields.forEach(fieldId => {
                    const field = document.getElementById(fieldId);
                    if (!field.value) {
                        field.classList.add('error');
                        document.getElementById(`${fieldId}-error`).style.display = 'block';
                        isValid = false;
                    } else {
                        field.classList.remove('error');
                        document.getElementById(`${fieldId}-error`).style.display = 'none';
                    }
                });
                
                // Fabrication year validation
                const year = document.getElementById('fabricationYear');
                if (year.value && (year.value < 1900 || year.value > 2023)) {
                    year.classList.add('error');
                    document.getElementById('fabricationYear-error').style.display = 'block';
                    isValid = false;
                }
                
                // Mileage validation
                const mileage = document.getElementById('mileage');
                if (mileage.value && mileage.value < 0) {
                    mileage.classList.add('error');
                    document.getElementById('mileage-error').style.display = 'block';
                    isValid = false;
                }
                
                // Color validation
                const colors = document.querySelectorAll('input[name="color"]:checked');
                if (colors.length === 0) {
                    document.getElementById('color-error').style.display = 'block';
                    isValid = false;
                } else {
                    document.getElementById('color-error').style.display = 'none';
                }
                
                return isValid;
            }
            
            // Form submission
            submitBtn.addEventListener('click', function(e) {
                e.preventDefault();
                if (validateStep2()) {
                    // Here you would typically send the form data to the server
                    alert('Registration submitted successfully!');
                    // Reset form
                    formContainer.style.transform = 'translateX(0)';
                    progress.style.width = '50%';
                    step2Indicator.classList.remove('active');
                    step1Indicator.classList.add('active');
                    document.getElementById('dmvForm').reset();
                }
            });
        });
We hope you would like this Calculator using html css and javascript code

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
Welcome