How to reset any form using jQuery?
Reset any form using jQuery
262
28-Jul-2021
Aryan Kumar
14-Jun-2023Sure, here is how you can reset any form using jQuery:
Code snippet
The reset() method of the Form object resets all of the form elements to their default values. This includes text input fields, select boxes, and radio buttons.
For example, the following code will reset the form with the ID myForm:
Code snippet
This will reset all of the form elements in the form to their default values.
You can also use the reset() method to reset a form that is not currently displayed on the page. For example, the following code will reset the form with the ID myForm even if it is not currently displayed:
Code snippet
This will load the form with the ID myForm from the file myForm.html and then reset it.
The reset() method is a useful way to clear all of the data from a form. This can be useful for forms that are used to collect data from users, such as contact forms or registration forms.
Here are some other things to keep in mind when using the reset() method: