How to clear form after submit in Javascript without using reset? Last Updated : 20 Jun, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Forms in JavaScript serve to gather specific user information, essential in various contexts like recruitment or inquiry submissions. While offline forms can be freely distributed, online forms must maintain a consistent structure for all users. After filling out a form, submission is crucial, but designers also tackle post-submission actions, such as clearing form fields without using the reset function, which we'll explore further in this section. Example: To demonstrate creating an HTML form using tables, assign IDs to fields like name, phone number, email, and description. Use JavaScript within a script tag to define a function, `fun()`, that resets field values to empty, ensuring data clearance without submission. html <!DOCTYPE html> <html> <head> <title>Resetting the form without reset method</title> <style> input[type=submit] { position: relative; float: right; } </style> </head> <body> <h1 style="color:green">GeeksforGeeks</h1> <b>clear form after submit in Javascript without using reset</b> <form id="d" action="/cgi-bin/test.cgi" name="geek"> <table cellspacing="0" cellpadding="3" border="1"> <tr> <td align="center">Username</td> <td> <input type="text" id="name" /> </td> </tr> <tr> <td align="center">Email</td> <td> <input type="text" id="mail" /> </td> </tr> <tr> <td align="center">Ph no</td> <td> <input type="tel" id="phone" /> </td> </tr> <tr> <td align="center"></td> <td> <input onclick="fun()" type="submit" value="Submit" /> </td> </tr> </table> </form> <script> function fun() { document.getElementById('name').value = ''; document.getElementById('mail').value = ''; document.getElementById('phone').value = ''; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article JavaScript - Prevent Users From Submitting a Form by Hitting Enter _mridul_bhardwaj_ Follow Improve Article Tags : JavaScript JavaScript-Misc JavaScript-Questions Similar Reads How to Disable Submit Button on Form Submit in JavaScript ? Forms are a crucial part of web development as they allow users to submit data to a server. However, sometimes we want to customize the behavior of HTML forms and prevent the default behavior from occurring. This allows you to create a more interactive and user-friendly web application. In this arti 3 min read JavaScript - Prevent Users From Submitting a Form by Hitting Enter We can use Onkeydown event attribute for Prevent Users From Submitting a Form by Hitting Enter in JavaScript. It will prevent the submission of form directly. 1. Using the 'Onkeydown' Event attributeThe onkeydown event attribute is an HTML attribute that is used to specify the behavior of a web page 2 min read How to clear cache memory using JavaScript? Clearing cache memory in JavaScript refers to managing or removing stored data like images, files, and resources that browsers save for faster loading. Although JavaScript cannot directly clear the browser cache, developers often use cache-busting techniques to ensure users receive updated content.B 2 min read How to submit a form by clicking a link in JavaScript ? Submitting a form by clicking a link in JavaScript involves binding a click event handler to the link element. When clicked, the handler triggers the form's submit action programmatically, allowing form submission without the need for a traditional submit button. ApproachHTML Structure:Basic HTML st 2 min read How to prevent duplicate submission in a form using jQuery? Preventing duplicate submission in a form using jQuery involves implementing measures to ensure that the form is only submitted once, regardless of how many times the user interacts with the submit button. To prevent duplicate form submissions in web applications using jQuery we can use various meth 4 min read How to Call a JavaScript Function using an onsubmit Event ? HTML has a form element that is used to get the data from the user and send the data to the server. Before the HTML form sends data to the server, it generates an event called "submit". This event can be utilized to execute a JavaScript function that can either validate the form data or notify the u 3 min read Like