How to reset modal form in jquery
- how to reset form in jquery
- how to clear form in jquery
- how to refresh form in jquery
- how to reset modal form in jquery
Onclick clear input field jquery!
How to Reset Form using jQuery with reset() Method?
Reset a form means clear all input fields data and returns to their initial default values. It can be useful where a user wants to clear all entered data or you want to reset the form after a successful submission.
The reset() method can easily reset the form data after clicking the reset button or successful form submission.
When invoked, this method restores the form’s fields to their default values.
Reset all input field jquery
The reset() method is used with jQuery to reset the form fields.
Syntax
$('selector')[0].reset();// OR
$('selector').get(0).reset();
Example 1: In this example, we use reset() method to reset the form data.
The form will be reset when user click on “Reset Form” button.
Output
Example 2: In this example we use jQuery to reset a form with ID d when the “Reset Form” button is clicked.
It prevents the default behavior and ensures the form returns to its initial state.
Output:
“Write less, do more”. You can learn jQuery from the ground up by following this jQuery Tuto
- how to clear input in jquery
- how to reset form after submit in jquery