Professional Multi Step Form - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Professional Multi-step Form</title> <style> body { font-family: 'Arial', sans-serif; background: linear-gradient(to right, #00c6ff, #0072ff); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; overflow: hidden; } .form-container { background: white; padding: 30px; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); width: 400px; max-width: 100%; transition: all 0.3s ease; overflow: hidden; } .form-container h1 { margin: 0 0 20px; font-size: 24px; text-align: center; color: #333; } .form-container .form-step { display: none; transition: all 0.3s ease; } .form-container .form-step.active { display: block; } .form-container .form-step input { width: 95%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 5px; outline: none; } .form-container .form-step .step-icon { font-size: 40px; text-align: center; color: #0072ff; } .form-container .form-step .emoji { font-size: 30px; text-align: center; } .form-container .form-step .form-controls { text-align: center; margin-top: 20px; } .form-container .form-step .form-controls button { padding: 10px 20px; border: none; border-radius: 5px; background: #0072ff; color: white; cursor: pointer; transition: background 0.3s ease; } .form-container .form-step .form-controls button:hover { background: #005bb5; } .form-container .progress-bar { position: relative; display: flex; justify-content: space-between; margin-bottom: 30px; } .form-container .progress-bar .step { width: 20px; height: 20px; background: #ddd; border-radius: 50%; position: relative; } .form-container .progress-bar .step::before { content: ''; position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; background: inherit; transform: translate(-50%, -50%); border-radius: inherit; transition: background 0.3s ease; } .form-container .progress-bar .step.active::before { background: #0072ff; } .form-container .progress-bar::after { content: ''; position: absolute; top: 50%; left: 10%; width: 80%; height: 2px; background: #ddd; z-index: -1; } .form-container .progress-bar .step.active + .step::after { background: #0072ff; } .form-container .form-step .form-controls .prev-btn { background: #ccc; margin-right: 10px; } .form-container .form-step .form-controls .prev-btn:hover { background: #999; } h2, p{ text-align: center; } </style> </head> <body> <div class="form-container"> <h1>Multi-step Form 📝</h1> <div class="progress-bar"> <div class="step"></div> <div class="step"></div> <div class="step"></div> <div class="step"></div> </div> <form id="multi-step-form"> <div class="form-step active"> <div class="step-icon">👤</div> <input type="text" placeholder="First Name" required> <input type="text" placeholder="Last Name" required> <div class="form-controls"> <button type="button" class="next-btn">Next</button> </div> </div> <div class="form-step"> <div class="step-icon">📧</div> <input type="email" placeholder="Email Address" required> <div class="form-controls"> <button type="button" class="prev-btn">Previous</button> <button type="button" class="next-btn">Next</button> </div> </div> <div class="form-step"> <div class="step-icon">🔒</div> <input type="password" placeholder="Password" required> <input type="password" placeholder="Confirm Password" required> <div class="form-controls"> <button type="button" class="prev-btn">Previous</button> <button type="button" class="next-btn">Next</button> </div> </div> <div class="form-step"> <div class="step-icon">✔️</div> <h2>Thank you! 🎊</h2> <p>Your registration is complete.</p> <div class="form-controls"> <button type="button" class="prev-btn">Previous</button> <button type="submit">Submit</button> </div> </div> </form> </div> <script> const nextBtns = document.querySelectorAll('.next-btn'); const prevBtns = document.querySelectorAll('.prev-btn'); const formSteps = document.querySelectorAll('.form-step'); const progressSteps = document.querySelectorAll('.progress-bar .step'); let formStepNum = 0; nextBtns.forEach(btn => { btn.addEventListener('click', () => { formStepNum++; updateFormSteps(); updateProgressbar(); }); }); prevBtns.forEach(btn => { btn.addEventListener('click', () => { formStepNum--; updateFormSteps(); updateProgressbar(); }); }); function updateFormSteps() { formSteps.forEach(formStep => { formStep.classList.contains('active') && formStep.classList.remove('active'); }); formSteps[formStepNum].classList.add('active'); } function updateProgressbar() { progressSteps.forEach((progressStep, idx) => { if (idx <= formStepNum) { progressStep.classList.add('active'); } else { progressStep.classList.remove('active'); } }); } </script> </body> </html>