splitforms.com
guide · form validation

jQuery Form Validation — Working Code for 2026

Working jQuery form validation using the jquery-validate plugin — required fields, email format, password confirmation, custom rules. Complete code, common gotchas, and how to wire it to a free splitforms backend.

html
<form id="signup" action="https://splitforms.com/api/submit" method="POST">
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />

  <label>Name<input name="name" required minlength="2" /></label>
  <label>Email<input name="email" type="email" required /></label>
  <label>Password<input name="password" type="password" required minlength="8" /></label>
  <label>Confirm password<input name="password_confirm" type="password" required /></label>

  <button type="submit">Sign up</button>
</form>

<!-- jQuery + jquery-validate CDN -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js"></script>

<script>
$("#signup").validate({
  rules: {
    name: { required: true, minlength: 2 },
    email: { required: true, email: true },
    password: { required: true, minlength: 8 },
    password_confirm: { required: true, equalTo: "[name=password]" },
  },
  messages: {
    name: { required: "Please enter your name." },
    email: { required: "We need your email.", email: "That's not a valid email." },
    password: { minlength: "Password must be at least 8 characters." },
    password_confirm: { equalTo: "Passwords don't match." },
  },
  submitHandler: function (form) {
    // Custom submission via AJAX (optional — if omitted, form submits normally)
    form.submit();
  },
});
</script>

jQuery's `jquery-validate` plugin is the legacy-but-still-popular way to add rich client-side validation to a form. It's older than HTML5 native validation and predates React, but it still solves the validation-UI problem cleanly: declarative rules, custom messages, optional async submission. If your codebase already uses jQuery, validate is the path of least resistance.

The rules object maps field names to validation rules. Built-in rules: `required`, `email`, `url`, `number`, `digits`, `minlength`, `maxlength`, `min`, `max`, `equalTo`, `creditcard`. Each rule can be a boolean (apply the rule) or a value (apply with that parameter). The messages object pairs rule failures with user-facing strings.

The `submitHandler` is the function called when validation passes. By default it submits the form natively (full page reload). Override it to submit via AJAX — call `$.ajax({...})` with the form's serialized data, handle the response in your own UI, and skip the page reload. This is how you wire jquery-validate to a JSON API like splitforms.

Modern alternatives: HTML5 native validation (no library, less power), React Hook Form + Zod (typed, framework-coupled), Bootstrap 5 validation (native attributes + Bootstrap classes). For new projects, prefer one of these. For existing jQuery codebases, validate stays the right choice.

AJAX submission with jquery-validate's submitHandler

javascript
$("#signup").validate({
  // ... rules as above ...
  submitHandler: function (form) {
    const formData = new FormData(form);
    $.ajax({
      url: form.action,
      method: "POST",
      data: formData,
      processData: false,
      contentType: false,
    }).done(function (res) {
      if (res.success) {
        $("#status").text("Thanks!");
        form.reset();
      } else {
        $("#status").text(res.message || "Error.");
      }
    }).fail(function () {
      $("#status").text("Network error.");
    });
  },
});

How to set this up

Step 01

Include jQuery + jquery-validate

Two <script> tags from CDN. ~30KB combined.

Step 02

Declare rules per field name

Map field names to rules (required, email, minlength, equalTo). Built-in rules cover ~90% of cases.

Step 03

Override messages for UX

Default messages are generic. Per-rule message overrides give your form a polished feel.

Step 04

(Optional) AJAX-submit via submitHandler

Override the default form submit to POST via $.ajax and update the DOM inline.

Declarative rules, custom messages, AJAX submit handler — all in 20 lines.

Frequently asked questions

What is jQuery form validation?

jQuery form validation typically refers to the jquery-validate plugin — a declarative client-side validation library that adds rules, custom messages, and async submission hooks to standard HTML forms. It predates HTML5 native validation but still ships clean APIs for complex validation scenarios.

Do I need jquery-validate for simple forms?

No. HTML5 native validation (required, type=email, pattern, minlength) handles simple cases without a library. Use jquery-validate when you need cross-field validation (password confirmation), custom rules, or rich error UI.

How do I add a custom validation rule in jQuery?

Use `$.validator.addMethod(name, function, message)` to register a custom rule. Example: `$.validator.addMethod("phoneUS", function (value) { return /^\(\d{3}\)\s\d{3}-\d{4}$/.test(value); }, "Phone must be (xxx) xxx-xxxx")`. Reference the rule by name in your rules object.

How do I validate a form on submit using jQuery?

Call `$(form).validate({rules, messages})` once at page load — jquery-validate hooks into the form's submit event automatically. When the user clicks submit, validation runs; if rules pass, the form submits; if they fail, errors render inline.

How do I submit a form via AJAX with jquery-validate?

Pass a `submitHandler` function in the validate config. Inside submitHandler, call $.ajax with the form's serialized data and handle the response in your own UI. This bypasses the default page-reload form submission.

Where do I get the jquery-validate CDN URL?

https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.min.js — pin to a specific version for reproducibility. Pair with jQuery: https://code.jquery.com/jquery-3.7.1.min.js.

Related guides

Form validation

React Form Validation — Working Code (React Hook Form + Zod)

Form validation

Bootstrap Form Validation — Native HTML + Bootstrap 5

HTML forms

HTML Form — How to Build and Submit Forms in HTML

AJAX submission

Submit Form with AJAX — Working Code for 2026

Ship the form, not the backend.

Free for 1,000 submissions/month. Email delivery, AI spam filtering, signed webhooks, real dashboard — all on the free plan. No credit card.

Get a free access key →