How to reset form in jquery or javascript


You can rest form using the following jquery :


Below are two functions which can reset form in jquery.

Solution 1 : How to reset form in jquery

 

function resetMyForm1(){
 $("#formId")[0].reset();
}

or you can reset the  form using javascript :

Solution 2 : How to reset form in jquery or JavaScript

You can reset the form using javascript as below:

function resetMyForm2(){
document.getElementById("formId").reset();
}

You can call the above function on button click example:

<button type="button" onclick="resetMyForm2()">Reset Form </button>

or 

<button type="button" onclick="resetMyForm1()">Reset Form </button>

Advertisements

Add Comment

📖 Read More