How to clear all inputs in HTML form?

PHPz
Release: 2023-09-01 11:21:09
forward
1130 people have browsed it

Using HTML forms, you can easily obtain user input. Use the

tag to add form elements to capture user input. Different types of form elements include text inputs, radio button inputs, submit buttons, etc.

TagHelps you get user input by using the type attribute. To clear all input in an HTML form, use thetag with the type attribute reset.

How to clear all inputs in HTML form?

Example 1

The following example demonstrates how to clear all input in an HTML form.

In this example, we will use document.getElementId to clear the text in the text field.

      Remove HTML 
Copy after login

When we click the clear button, the text in the input (text area) field will be cleared.

The Chinese translation of

Example 2

is:

Example 2

The following example demonstrates how to clear all input in an HTML form.

In this example, we will use the reset button to clear the text in the text field.

      Clear all the input in HTML forms 
Copy after login

When we click the clear button, the text in the input (text area) field will be cleared.

Example 3

The following example demonstrates how to clear all input in an HTML form.

In this example, we are going to use onclick() method to clear the text in the text field.

      Clear all the input in HTML forms 
Copy after login
The Chinese translation of

Example 4

is:

Example 4

You can try running the following code to clear all inputs in the HTML form -

   
Student Name:

Student Subject:

Copy after login

Once the reset button is clicked, the form will be cleared.

The above is the detailed content of How to clear all inputs in HTML form?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!