Posted on

dyvdf



    
    
    <title>Form Example</title>
    
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        form {
            max-width: 600px;
            margin: auto;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"],
        input[type="password"],
        input[type="email"],
        input[type="tel"],
        select {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
        }
        input[type="button"],
        input[type="reset"],
        input[type="submit"] {
            padding: 10px 15px;
            margin: 5px;
            cursor: pointer;
        }
        .age-group {
            display: flex;
            align-items: center;
        }
        .age-group input {
            margin-left: 10px;
        }
    


    <h1>Registration Form</h1>
    
        <div class="form-group">
            <label for="firstname">First Name:</label>
            
        </div>

        <div class="form-group">
            <label for="lastname">Last Name:</label>
            
        </div>

        <div class="form-group">
            <label for="password">Password:</label>
            
        </div>

        <div class="form-group">
            <label for="dob">Date of Birth:</label>
            
        </div>

        <div class="form-group">
            <label for="email">Email:</label>
            
        </div>

        <div class="form-group">
            <label for="phone">Phone Number:</label>
            
        </div>

        <div class="form-group">
            <label for="state">State:</label>
            
                Select a state
                Alabama
                Alaska
                Arizona
                Arkansas
                California
                <!-- Add other states as needed -->
            
        </div>

        <div class="form-group">
            <label for="age">Age:</label>
            <div class="age-group">
                
                
            </div>
        </div>

        <div class="form-group">
            <label for="search">Google Search:</label>
            
            
        </div>

        <div class="form-group">
            
            
        </div>
    

    
        function calculateAge() {
            const dob = document.getElementById('dob').value;
            if (!dob) {
                alert('Please select a date of birth.');
                return;
            }
            const birthDate = new Date(dob);
            const today = new Date();
            let age = today.getFullYear() - birthDate.getFullYear();
            const monthDiff = today.getMonth() - birthDate.getMonth();
            if (monthDiff &lt; 0 || (monthDiff === 0 &amp;&amp; today.getDate() &lt; birthDate.getDate())) {
                age--;
            }
            document.getElementById(&#039;age&#039;).value = age;
        }

        function performSearch() {
            const query = document.getElementById(&#039;search&#039;).value;
            if (query) {
                window.open(&#039;https://www.google.com/search?q=&#039; + encodeURIComponent(query), &#039;_blank&#039;);
            } else {
                alert(&#039;Please enter a search query.&#039;);
            }
        }