Nature 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>Nature Multi-step Form</title> <style> body { font-family: 'Arial', sans-serif; background: #D9AFD9; /* fallback for old browsers */ background: -webkit-linear-gradient(to right, #97D9E1, #D9AFD9); /* Chrome 10-25, Safari 5.1-6 */ background: linear-gradient(to right, #97D9E1, #D9AFD9); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; overflow: hidden; } .form-container { background: rgba(255, 255, 255, 0.8); padding: 35px; border-radius: 15px; box-shadow: 0 8px 20px rgba(0,0,0,0.2); width: 450px; max-width: 100%; transition: all 0.3s ease; overflow: hidden; } .form-container h1 { margin: 0 0 25px; font-size: 24px; text-align: center; color: #2F4F4F; } .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: 12px; margin: 10px 0; border: 2px solid #ccc; border-radius: 8px; outline: none; } .form-container .form-step .step-icon { font-size: 45px; text-align: center; color: #3CB371; } .form-container .form-step .emoji { font-size: 35px; text-align: center; } .form-container .form-step .form-controls { text-align: center; margin-top: 25px; } .form-container .form-step .form-controls button { padding: 10px 20px; border: none; border-radius: 8px; background: #3CB371; color: white; cursor: pointer; transition: background 0.3s ease; } .form-container .form-step .form-controls button:hover { background: #2E8B57; } .form-container .progress-bar { position: relative; display: flex; justify-content: space-between; margin-bottom: 30px; } .form-container .progress-bar .step { width: 22px; height: 22px; background: #ccc; 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: #3CB371; } .form-container .progress-bar::after { content: ''; position: absolute; top: 50%; left: 8%; width: 84%; height: 2px; background: #ccc; z-index: -1; } .form-container .progress-bar .step.active + .step::after { background: #3CB371; } .form-container .form-step .form-controls .prev-btn { background: #999; margin-right: 15px; } .form-container .form-step .form-controls .prev-btn:hover { background: #777; } h2, p{ text-align: center; } </style> </head> <body> <div class="form-container"> <h1>Nature 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="nature-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>