SyntaxStudy
Sign Up
jQuery Beginner 3 min read

Resetting Forms

Form Reset

Reset a form to its initial values with the native reset() method, then clear any validation classes or custom state.

Example
$("#resetBtn").on("click", function() {
  // Native reset
  $("#myForm")[0].reset();

  // Clear custom validation states
  $(".is-invalid, .is-valid").removeClass("is-invalid is-valid");
  $(".invalid-feedback").text("");

  // Clear custom UI
  $("#charCount").text("200 characters remaining");
});
Pro Tip

Call [0].reset() on the DOM element, not .reset() on the jQuery object.