JavaScript reset17 Mar 2025 | 2 min read In HTML, we can use the reset button to reset the form. In this article, we are discussing how to reset the form using JavaScript. In JavaScript, the reset() method does the same thing as the HTML reset button. It is used to clear all the values of the form elements. It can be used to set the values to default. It does not require any parameter values and also does not return any value. SyntaxExampleTo illustrate the use of reset() method in JavaScript, we are creating a simple HTML document into which we have created a form with the id = "myForm". In this form, there are four text fields: "First Name", "Last Name", "Age", and "E-mail Id". There are two buttons that are "Submit", and "Reset data". When we click the Reset data button, it calls the function fun(), where we have defined the JavaScript's reset() method. In the function fun(), we are first taking the reference of the form required to reset, and then we are applying the reset() method over it. Now, let's see the code for the same. Output After the execution of the above code, the output will be - ![]() Now, let's fill the textfield values - ![]() Finally, on clicking the Reset data button, the values will be restored - ![]() Next TopicNumber-guessing-game-in-javascript |
The current URL in the web is important for multiple use cases like analytics tracking, dynamic rendering or implementing conditional logic based on the page URL. JavaScript offers some methods and properties that help the developers to manipulate the URL of the current webpage. In this article,...
12 min read
A binary number is a numerical system having a basis, or radix, of two in terms of number systems. This indicates that all values are represented by just the two numbers, 0 and 1. A "bit" is the abbreviation for a binary digit, which is...
4 min read
What is an Index? An index in programming denotes a specific location internal to the structure of a record. In arrays, strings, and other iterable collections, it serves as a pointer to the factors. Because indices in JavaScript are totally zero-based, counting starts at 0 rather than...
12 min read
Introduction: The number guessing game is a work of art and engaging programming exercise that assists designers with improving their logical reasoning and critical thinking abilities. In this article, we will dig into the hypothetical parts of making a number guessing game utilizing JavaScript. This famous game...
8 min read
? In JavaScript, an array is an effective way to store a collection of items. One of the basic things that we can do with an array is looping or iterating over each of the elements there. Let's see different ways how we can loop through an...
6 min read
You may want to include the copy feature while creating complex web pages and applications. Instead of selecting the text and pressing a few keys on the keyboard to copy it, your users may now copy text by clicking a button or icon. When someone has...
3 min read
We will understand the in this article. ASCII It stands for the American Standard Code for Information Interchange. It is a character encoding format utilized to communicate between computers. It provides standard numeric values to numerals, letters, etc. There are 128 unique characters in ASCII. It contains...
3 min read
JavaScript provides a variety of operators to evaluate mathematical and logical operators and expressions in your programs. Increment and decrement operators are two kinds of unary operators in JavaScript that add or subtract a value of 1 from an operand. The purpose of this article is...
3 min read
JavaScript compilers are crucial in contemporary software development, transforming the execution of JavaScript code and enhancing performance. A JavaScript compiler converts JavaScript code from a readable form into machine code for web browsers or runtime environments. In contrast to interpreters, compilers analyze and translate complete scripts...
7 min read
There is full control to handle loop statements in JavaScript. Sometimes, a situation occurs when we require to skip some code of the loop and move to the iteration. It can be achieved by using JavaScript's continue statement. The continue statement in JavaScript is used...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India