Blog

HTML Multi-Step Form with jQuery and Validation

HTML multi-step form with jQuery showing numbered progress, input fields, and a review panel

To build an HTML multi-step form with jQuery, divide one form into fieldsets, show one step at a time, and validate the current step before moving forward. Keep the values in their original inputs, provide a Back button, and show a review screen before the final action.

This tutorial recreates a question-style form with four steps: name, organization, contact details, and review. The responsive demo includes inline validation, progress, keyboard navigation, and a local completion screen. Download the complete HTML, CSS, JavaScript, and bundled jQuery files.

How the multi-step form works

Step Fields or action Validation
1. Name Ask what to call the visitor. 2–60 characters after trimming.
2. Team Ask for an organization or team. 2–100 characters after trimming.
3. Contact Collect an email and optional phone. Email syntax; basic phone format if entered.
4. Review Display the current answers as text. Recheck all fields before local completion.

Next checks the active step. Back preserves the answers so visitors can revise them. Completing this demonstration displays an on-page message; it does not submit a registration or send an email.

Live demo: HTML multi-step form with jQuery

Try a sample name such as Maya, a team such as Example Studio, and maya@example.com. The form uses jQuery already loaded by this website. Your entries stay in page memory and are cleared by Reset.

Try the question-style form

Use sample details to explore the steps. This demo keeps values in page memory only; completion sends no data and does not email anyone.

Loading the form. JavaScript and jQuery are required.

Ready. Start with your name.

Enable JavaScript and jQuery for the wizard. No form data can be submitted from this demonstration.

1. Group related fields with fieldset and legend

Use one form with a fieldset for each step. Give every input a label, keep IDs unique, and connect help and error text using aria-describedby. Inactive steps use the hidden attribute.

<form id="wizard" novalidate>
  <fieldset data-step="0">
    <legend>What should we call you?</legend>
    <label for="name">Your name</label>
    <input id="name" name="name" required minlength="2" maxlength="60">
  </fieldset>
  <fieldset data-step="1" hidden>
    <legend>Which team are you with?</legend>
    <label for="team">Organization or team</label>
    <input id="team" name="team" required>
  </fieldset>
  <button type="button" id="next">Next</button>
</form>

This is a structural excerpt. The complete ZIP adds the remaining steps, errors, validation, and submission handling. Its form starts hidden until JavaScript installs the demo handlers, so an unavailable script does not expose a misleading submission button.

2. Use jQuery to manage the active step

Keep a single step index and update all related UI in one function: fieldset visibility, progress, the current-step marker, and navigation buttons. Scope selectors to the form so the wizard does not change unrelated fields elsewhere on the page.

const $form = jQuery('#wizard');
const $steps = $form.find('fieldset');
let current = 0;

function showStep(index) {
  current = index;
  $steps.each(function (i) {
    this.hidden = i !== current;
  });
}

$form.find('#next').on('click', function () {
  // validateCurrentStep() belongs to your form's validation logic.
  if (validateCurrentStep()) showStep(current + 1);
});

jQuery's .on() documentation explains event binding. This example needs jQuery core only; it does not require Bootstrap, jQuery UI, or a separate validation plugin. The download pins jQuery 3.7.1 to match this site's loaded version and includes a local copy for offline use.

3. Validate the current step before Next

Trim text before checking required values, so a field containing spaces is not accepted as a name. Check only the active step when moving forward; inactive required fields should not block the visitor before they reach them. Display a clear inline error and focus the first invalid field.

The contact step uses an email input's validity state for syntax and a deliberately simple optional phone rule. Neither check confirms that the address or phone belongs to a real person. The limits in the demo are example design choices; adapt them to your audience.

const email = document.querySelector('#email');
email.value = email.value.trim();

if (!email.value || !email.validity.valid) {
  // Show an associated error, set aria-invalid, and focus this input.
}

The novalidate attribute lets the wizard control when errors appear. It does not make invalid input valid. MDN's constraint validation guide explains native validity checks and why a backend must also validate incoming data.

4. Preserve answers and refresh the review screen

Leave the input elements in place when hiding their fieldsets. Back can then reveal the original values without copying state into another storage layer. Each visit to Review reads the latest values again, so edits appear immediately.

Insert visitor-provided values using .text(), rather than building HTML from their answers:

jQuery('[data-review="name"]').text(
  jQuery('#name').val().trim()
);

jQuery's .text() reference describes setting text content. This keeps markup-like input visible as text instead of interpreting it as page markup. The same approach is used for the personalized contact question.

5. Handle keyboard navigation and the final action

Use type="button" for Back, Next, and Reset. Reserve type="submit" for the final action, then handle the form's submit event explicitly. In this demo, Enter inside an input validates and advances one step. The final submit handler rechecks every input step before displaying completion.

The demo always prevents the native form submission. A production form needs a real backend request and should show success only after that server confirms it. Repeat validation on the server, add CSRF and abuse protection as appropriate, and explain how the submitted data is used. The downloadable example has no email handler, database, or remote submission endpoint.

Make the form easier to use on small screens

The layout keeps labels above inputs, wraps the navigation buttons, and preserves a visible focus outline. A native progress element and a numbered step list describe position; moving between steps places focus on the new legend. Inline errors are connected to their inputs, and a live status announces navigation and validation results.

The four-step indicator shows the current location. Reaching Review is not the same as successfully sending data. These features support keyboard and assistive-technology use, but you should still test your final implementation with your audience and supported devices.

Download and run the complete project

Extract the ZIP and open index.html in a modern browser. All files, including jQuery and its license, are included. No server, build process, or network connection is needed for the standalone demo.

multi-step-form-demo/
├── index.html
├── style.css
├── script.js
├── README.md
└── vendor/
    ├── jquery-3.7.1.min.js
    └── LICENSE-jquery.txt

When adapting the form for WordPress, enqueue your script with WordPress's existing jquery dependency. Do not add a second jQuery copy to a page that already loads it. If an optimization plugin delays scripts, preserve the dependency order so jQuery is ready before the wizard initializes.

Common multi-step form problems

Problem Fix
Next submits or reloads the page Set Next to type="button" and handle the submit event.
Hidden required fields block progress Validate the active step explicitly and recheck all fields at the final action.
Spaces pass a required text check Trim the value before applying length rules.
Review shows an old answer Rebuild the review text whenever the visitor enters Review.
The form changes another widget Scope selectors to the wizard and use unique IDs.
The form stays at Loading Check that JavaScript is enabled and jQuery loads before the form script.

Frequently asked questions

Can I add more form steps?

Yes. Add the fieldset, progress label, and validation rules together. Update the step count and last-step button logic in the script.

Do I need a jQuery validation plugin?

No. This example combines jQuery events with explicit field checks and native email validity. A plugin is optional if its behavior suits your form.

Will Back erase the entered values?

No. It reveals the existing inputs. Reset and Start again deliberately clear the fields and review values.

Does this form send an email?

No. The final button completes a local demonstration. Add a backend and real response handling when building an actual contact or registration form.

Does the demo save entries after a refresh?

The script does not persist entries in cookies or browser storage. Reset clears its current values. Browser autofill and session restoration are separate browser features; the demo requests autocomplete off.

Can I build a multi-step form without jQuery?

Yes. The same fieldsets, validation, visibility, and focus logic can be implemented with native JavaScript. This tutorial uses jQuery to match the original post's topic.

Try the complete form flow

Test empty fields, invalid contact details, Back/edit behavior, review updates, keyboard navigation, completion, and reset. The source ZIP includes the complete demo and notes for adapting it to a real website.