Form Reset
Reset a form to its initial values with the native reset() method, then clear any validation classes or custom state.
Reset a form to its initial values with the native reset() method, then clear any validation classes or custom state.
$("#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");
});
Call [0].reset() on the DOM element, not .reset() on the jQuery object.