Form
Preview
Edit
Download
Run
Download Options
HTML File
Download as .html file
CSS File
Download as .css file
JavaScript File
Download as .js file
Combined HTML
All code in one HTML file
Project ZIP
All files in a ZIP archive
Cancel
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Luxury Contact Form</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="form-container"> <div class="form-decoration"></div> <form id="luxuryForm" class="luxury-form"> <div class="form-header"> <h1><span class="gradient-text">Get in Touch</span></h1> <p>Our concierge will respond within 24 hours</p> </div> <div class="form-group floating-label"> <input type="text" id="name" name="name" required> <label for="name">Full Name</label> <i class="fas fa-user"></i> <span class="error-message"></span> </div> <div class="form-group floating-label"> <input type="email" id="email" name="email" required> <label for="email">Email Address</label> <i class="fas fa-envelope"></i> <span class="error-message"></span> </div> <div class="form-group floating-label"> <select id="service" name="service" required> <option value=""></option> <option value="consultation">Private Consultation</option> <option value="membership">Membership Inquiry</option> <option value="partnership">Partnership</option> <option value="other">Other</option> </select> <label for="service">Service Interest</label> <i class="fas fa-chevron-down"></i> <span class="error-message"></span> </div> <div class="form-group floating-label"> <textarea id="message" name="message" rows="3" required></textarea> <label for="message">Your Message</label> <i class="fas fa-pen-fancy"></i> <span class="error-message"></span> </div> <div class="form-group checkbox-group"> <input type="checkbox" id="consent" name="consent" required> <label for="consent">I agree to the <a href="#">privacy policy</a></label> <span class="error-message"></span> </div> <button type="submit" class="submit-btn"> <span class="btn-text">Send Message</span> <div class="btn-loader"> <div class="loader-dot"></div> <div class="loader-dot"></div> <div class="loader-dot"></div> </div> </button> </form> <div class="form-success"> <div class="success-icon"> <i class="fas fa-check"></i> </div> <h2>Message Sent</h2> <p>We'll contact you shortly</p> <button class="reset-btn">Send Another</button> </div> </div> <script src="script.js"></script> </body> </html>
CSS
:root { --primary: #6a11cb; --secondary: #2575fc; --accent: #ff4d8d; --dark: #121218; --light: #f8f9fa; --gray: #e0e0e0; --glass: rgba(255, 255, 255, 0.05); --success: #4BB543; } * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Montserrat', sans-serif; background: linear-gradient(135deg, var(--dark), #1a1a2e); color: var(--light); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; } .form-container { position: relative; width: 100%; max-width: 600px; background: var(--glass); backdrop-filter: blur(12px); border-radius: 20px; overflow: hidden; box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.1); padding: 40px; } .form-decoration { position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(106,17,203,0.1) 0%, rgba(37,117,252,0) 70%); animation: rotate 20s linear infinite; z-index: -1; } @keyframes rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .form-header { text-align: center; margin-bottom: 40px; } .form-header h1 { font-size: 2.5rem; margin-bottom: 10px; font-weight: 600; } .gradient-text { background: linear-gradient(90deg, var(--primary), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; } .form-header p { color: rgba(255, 255, 255, 0.7); font-size: 0.9rem; } .luxury-form { display: flex; flex-direction: column; gap: 25px; } .form-group { position: relative; } .floating-label { position: relative; margin-bottom: 15px; } .floating-label input, .floating-label select, .floating-label textarea { width: 100%; padding: 20px 20px 10px 45px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px; color: var(--light); font-size: 1rem; transition: all 0.3s ease; } .floating-label textarea { min-height: 120px; resize: vertical; padding-top: 25px; } .floating-label select { appearance: none; -webkit-appearance: none; } .floating-label label { position: absolute; top: 20px; left: 45px; color: rgba(255, 255, 255, 0.6); pointer-events: none; transition: all 0.3s ease; font-size: 0.9rem; } .floating-label i { position: absolute; top: 18px; left: 15px; color: rgba(255, 255, 255, 0.6); transition: all 0.3s ease; } .floating-label input:focus, .floating-label select:focus, .floating-label textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255, 77, 141, 0.2); } .floating-label input:focus ~ label, .floating-label select:focus ~ label, .floating-label textarea:focus ~ label, .floating-label input:not(:placeholder-shown) ~ label, .floating-label select:not([value=""]) ~ label, .floating-label textarea:not(:placeholder-shown) ~ label { top: 8px; left: 45px; font-size: 0.7rem; color: var(--accent); } .floating-label input:focus ~ i, .floating-label select:focus ~ i, .floating-label textarea:focus ~ i { color: var(--accent); } .error-message { display: block; color: #ff3860; font-size: 0.75rem; margin-top: 5px; height: 15px; } .checkbox-group { display: flex; align-items: center; margin-top: 10px; } .checkbox-group input { appearance: none; width: 18px; height: 18px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 4px; margin-right: 10px; position: relative; cursor: pointer; transition: all 0.2s ease; } .checkbox-group input:checked { background-color: var(--accent); border-color: var(--accent); } .checkbox-group input:checked::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; color: white; font-size: 10px; top: 50%; left: 50%; transform: translate(-50%, -50%); } .checkbox-group label { font-size: 0.85rem; color: rgba(255, 255, 255, 0.7); cursor: pointer; } .checkbox-group a { color: var(--accent); text-decoration: none; transition: all 0.2s ease; } .checkbox-group a:hover { text-decoration: underline; } .submit-btn { position: relative; background: linear-gradient(90deg, var(--primary), var(--secondary)); color: white; border: none; padding: 15px; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer; overflow: hidden; transition: all 0.3s ease; margin-top: 10px; display: flex; justify-content: center; align-items: center; height: 50px; } .submit-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(106, 17, 203, 0.4); } .submit-btn:active { transform: translateY(0); } .submit-btn::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); transition: 0.5s; } .submit-btn:hover::before { left: 100%; } .btn-loader { display: none; gap: 5px; position: absolute; } .loader-dot { width: 8px; height: 8px; background-color: white; border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; } .loader-dot:nth-child(2) { animation-delay: 0.2s; } .loader-dot:nth-child(3) { animation-delay: 0.4s; } @keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } } .form-success { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--glass); backdrop-filter: blur(12px); padding: 40px; text-align: center; opacity: 0; pointer-events: none; transition: all 0.5s ease; } .form-success.active { opacity: 1; pointer-events: all; } .success-icon { width: 80px; height: 80px; background-color: var(--success); border-radius: 50%; display: flex; justify-content: center; align-items: center; margin-bottom: 20px; animation: scaleIn 0.5s ease; } .success-icon i { font-size: 2.5rem; color: white; } @keyframes scaleIn { 0% { transform: scale(0); } 80% { transform: scale(1.1); } 100% { transform: scale(1); } } .form-success h2 { font-size: 2rem; margin-bottom: 10px; background: linear-gradient(90deg, var(--success), #2ecc71); -webkit-background-clip: text; background-clip: text; color: transparent; } .form-success p { color: rgba(255, 255, 255, 0.7); margin-bottom: 30px; } .reset-btn { background: transparent; color: var(--accent); border: 1px solid var(--accent); padding: 12px 30px; border-radius: 30px; font-size: 0.9rem; cursor: pointer; transition: all 0.3s ease; } .reset-btn:hover { background: rgba(255, 77, 141, 0.1); } /* Responsive Design */ @media (max-width: 768px) { .form-container { padding: 30px 20px; } .form-header h1 { font-size: 2rem; } .floating-label input, .floating-label select, .floating-label textarea { padding: 18px 18px 8px 40px; } .floating-label label { left: 40px; } .floating-label i { left: 12px; } } @media (max-width: 480px) { .form-header h1 { font-size: 1.8rem; } .checkbox-group label { font-size: 0.8rem; } }
JavaScript
document.addEventListener('DOMContentLoaded', function() { const form = document.getElementById('luxuryForm'); const successMessage = document.querySelector('.form-success'); const submitBtn = document.querySelector('.submit-btn'); const btnText = document.querySelector('.btn-text'); const btnLoader = document.querySelector('.btn-loader'); const resetBtn = document.querySelector('.reset-btn'); // Form validation form.addEventListener('submit', function(e) { e.preventDefault(); if (validateForm()) { // Show loading state submitBtn.disabled = true; btnText.style.display = 'none'; btnLoader.style.display = 'flex'; // Simulate form submission setTimeout(() => { form.reset(); successMessage.classList.add('active'); submitBtn.disabled = false; btnText.style.display = 'block'; btnLoader.style.display = 'none'; }, 2000); } }); // Reset form resetBtn.addEventListener('click', function() { successMessage.classList.remove('active'); }); // Real-time validation const inputs = form.querySelectorAll('input, select, textarea'); inputs.forEach(input => { input.addEventListener('input', () => { validateField(input); }); // For select elements if (input.tagName === 'SELECT') { input.addEventListener('change', () => { validateField(input); }); } }); // Validate entire form function validateForm() { let isValid = true; inputs.forEach(input => { if (!validateField(input)) { isValid = false; } }); return isValid; } // Validate individual field function validateField(field) { const errorElement = field.closest('.form-group').querySelector('.error-message'); let isValid = true; let errorMessage = ''; if (field.required && !field.value.trim()) { isValid = false; errorMessage = 'This field is required'; } else if (field.type === 'email' && !isValidEmail(field.value)) { isValid = false; errorMessage = 'Please enter a valid email'; } else if (field.id === 'consent' && !field.checked) { isValid = false; errorMessage = 'You must agree to continue'; } // Update UI if (isValid) { field.style.borderColor = ''; errorElement.textContent = ''; } else { field.style.borderColor = '#ff3860'; errorElement.textContent = errorMessage; } return isValid; } // Email validation helper function isValidEmail(email) { const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return re.test(email); } // Animate form elements on load const formGroups = document.querySelectorAll('.form-group'); formGroups.forEach((group, index) => { group.style.opacity = '0'; group.style.transform = 'translateY(20px)'; setTimeout(() => { group.style.transition = 'opacity 0.5s ease, transform 0.5s ease'; group.style.opacity = '1'; group.style.transform = 'translateY(0)'; }, 100 * index); }); });
Output Preview
Desktop
Mobile
Fullscreen