search
HomeWeb Front-endJS TutorialBuilding a Premium Multi-Step Form with Animations

Building a Premium Multi-Step Form with Animations

In this tutorial, we'll walk through creating a premium, interactive multi-step form with smooth animations and client-side validation using HTML, CSS, and JavaScript. This form provides an enhanced user experience and looks like something straight out of 2025!

Live Demo: https://codepen.io/HanGPIIIErr/pen/ZYzbrqW

Table of Contents

  1. Introduction
  2. Prerequisites
  3. Project Structure
  4. HTML Markup
  5. Styling with CSS
  6. Adding Interactivity with JavaScript
  7. Conclusion

1.Introduction

Multi-step forms are an excellent way to enhance user experience by breaking down lengthy forms into manageable sections. In this tutorial, we'll create a five-step form that includes:

  • Personal Information
  • Preferences
  • Image Upload
  • Comments
  • Summary and Submission

We'll add smooth animations between steps and validate user inputs to ensure data integrity.

Prerequisites

Basic understanding of HTML, CSS, and JavaScript
Familiarity with form elements and event handling in JavaScript

Project Structure

We'll have three main files:

index.html — The HTML structure
style.css — The styling for our form
script.js — The JavaScript to handle form interactions
Let's start by setting up our HTML file.



    <meta charset="UTF-8">
    <title>Premium Multi-Step Form</title>
    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,600&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">


    

Explanation

  • Form Steps: Each step is wrapped in a div with the class form-step.
  • Active Class: The first step has the class active to display it initially.
  • Navigation Buttons: Each step (except the first and last) has "Previous" and "Next" buttons.
  • Summary Section: The last step displays a summary of the entered information.

Styling with CSS

Now, let's style our form to give it that premium feel.

/* style.css */

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #1abc9c, #16a085);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

form {
    width: 90%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.95);
    padding: 3em;
    border-radius: 20px;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.form-step {
    position: absolute;
    width: 100%;
    opacity: 0;
    transform: scale(0.8) translateY(50px);
    transition: all 0.5s ease;
}

.form-step.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    position: relative;
}

.step-header {
    position: absolute;
    top: -30px;
    right: 30px;
    background: #16a085;
    color: #fff;
    padding: 0.5em 1em;
    border-radius: 30px;
    font-weight: 600;
    animation: slideIn 0.5s forwards;
}

h2 {
    margin-bottom: 1em;
    color: #333;
    font-weight: 600;
    text-align: center;
    animation: fadeInDown 0.5s ease-in-out;
}

label {
    display: block;
    margin-top: 1em;
    color: #555;
    font-weight: 500;
    animation: fadeInUp 0.5s ease-in-out;
}

input[type="text"],
input[type="email"],
input[type="file"],
textarea {
    width: 100%;
    padding: 0.75em 1em;
    margin-top: 0.5em;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s;
    animation: fadeInUp 0.5s ease-in-out;
}

input:focus,
textarea:focus {
    border-color: #1abc9c;
}

input[type="checkbox"] {
    margin-right: 0.5em;
}

.buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 2em;
    animation: fadeInUp 0.5s ease-in-out;
}

button {
    padding: 0.75em 2em;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background 0.3s, transform 0.3s, box-shadow 0.3s;
}

.next-step,
.prev-step {
    background: #1abc9c;
    color: #fff;
}

.next-step:hover,
.prev-step:hover {
    background: #16a085;
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

button[type="submit"] {
    background: #e74c3c;
    color: #fff;
    margin-left: auto;
}

button[type="submit"]:hover {
    background: #c0392b;
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

#summary p {
    margin: 1em 0;
    color: #333;
    font-weight: 500;
    animation: fadeInUp 0.5s ease-in-out;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

Explanation

  • Background Gradient: A smooth gradient provides a modern feel.
  • Form Styling: We use backdrop-filter for a glassmorphism effect.
  • Transitions and Animations: Smooth transitions and keyframe animations enhance interactivity.
  • Button Effects: Hover effects with slight movement and shadow for depth.
  • Adding Interactivity with JavaScript

Let's make our form functional.

document.addEventListener('DOMContentLoaded', function() {
    const form = document.getElementById('multi-step-form');
    const steps = document.querySelectorAll('.form-step');
    const nextBtns = document.querySelectorAll('.next-step');
    const prevBtns = document.querySelectorAll('.prev-step');
    const summary = document.getElementById('summary');
    let currentStep = 0;

    nextBtns.forEach(btn => {
        btn.addEventListener('click', () => {
            if (validateStep()) {
                steps[currentStep].classList.remove('active');
                currentStep++;
                if (currentStep  {
        btn.addEventListener('click', () => {
            steps[currentStep].classList.remove('active');
            currentStep--;
            steps[currentStep].classList.add('active');
        });
    });

    form.addEventListener('submit', (e) => {
        e.preventDefault();
        alert('Form successfully submitted!');
        form.reset();
        steps[currentStep].classList.remove('active');
        currentStep = 0;
        steps[currentStep].classList.add('active');
    });

    function validateStep() {
        let stepIsValid = true;
        const currentInputs = steps[currentStep].querySelectorAll('input, textarea');
        currentInputs.forEach(input => {
            if (!input.checkValidity()) {
                input.reportValidity();
                stepIsValid = false;
            }
        });
        return stepIsValid;
    }

    function displaySummary() {
        const name = document.getElementById('name').value || 'N/A';
        const email = document.getElementById('email').value || 'N/A';
        const prefs = Array.from(document.querySelectorAll('input[name="pref"]:checked')).map(el => el.value).join(', ') || 'None';
        const comments = document.getElementById('comments').value || 'None';

        summary.innerHTML = `
            <p><strong>Name:</strong> ${name}</p>
            <p><strong>Email:</strong> ${email}</p>
            <p><strong>Preferences:</strong> ${prefs}</p>
            <p><strong>Comments:</strong> ${comments}</p>
        `;
    }

    // Initialize steps
    steps.forEach((step, index) => {
        if (index !== currentStep) {
            step.classList.remove('active');
        } else {
            step.classList.add('active');
        }
    });
});

Explanation

  • Event Listeners: For "Next" and "Previous" buttons to navigate between steps.
  • Validation: validateStep() ensures required fields are filled.
  • Summary Display: displaySummary() compiles the entered data for the user to review.
  • Form Submission: On submission, the form resets and returns to the first step.

? Conclusion: Forging the Future of Gladiators Battle

The latest enhancements to Gladiators Battle mark a significant leap toward providing a seamless and captivating experience for all players. With an enriched tutorial system, modular components, a thriving guild ecosystem, and optimized mini-games, the game is evolving into the ultimate gladiatorial RPG.

Whether you're a newcomer exploring the arena for the first time or a seasoned warrior dominating the battlefield, these updates ensure everyone can forge their own epic legacy.

? Join the Journey!

We are actively seeking feedback from players and developers alike. Dive into Gladiators Battle and share your thoughts with us.

? Website: https://gladiatorsbattle.com
?️ Support Us on Kickstarter: https://www.kickstarter.com/projects/gladiatorsbattle/gladiators-battle-forge-your-legend-in-the-ultimate-arena
? Follow Us on X (formerly Twitter): https://x.com/GladiatorsBT
? Connect on LinkedIn: https://www.linkedin.com/in/pierre-romain-lopez
? Join the Community on Discord: https://discord.gg/YBNF7KjGwx

Thank you for your unwavering support as we continue to develop Gladiators Battle. Your feedback, ideas, and enthusiasm are the driving forces behind our progress.

Let the adventure continue—Ave, Gladiators! ?✨

If you have any questions or suggestions, please leave a comment below!

The above is the detailed content of Building a Premium Multi-Step Form with Animations. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
JavaScript in Action: Real-World Examples and ProjectsJavaScript in Action: Real-World Examples and ProjectsApr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

JavaScript and the Web: Core Functionality and Use CasesJavaScript and the Web: Core Functionality and Use CasesApr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding the JavaScript Engine: Implementation DetailsUnderstanding the JavaScript Engine: Implementation DetailsApr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: The Learning Curve and Ease of UsePython vs. JavaScript: The Learning Curve and Ease of UseApr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python vs. JavaScript: Community, Libraries, and ResourcesPython vs. JavaScript: Community, Libraries, and ResourcesApr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

From C/C   to JavaScript: How It All WorksFrom C/C to JavaScript: How It All WorksApr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Atom editor mac version download

Atom editor mac version download

The most popular open source editor