Possible reasons why the input type="reset" tag in HTML is invalid (does not work).

Possible reasons why the input type="reset" tag in HTML is invalid (does not work).
When using the <html:reset> tag, sometimes we will find that the reset button is invalid and clicking the button does not clear the input box.

Here’s why:

The w3c website has this description (http://www.w3school.com.cn/htmldom/dom_obj_reset.asp)
"For each occurrence of the <input type="reset"> tag in an HTML form, a Reset object is created. When the reset button is clicked, the values ​​of all input elements in the containing form are reset to their default values. The default values ​​are specified by the HTML value attribute or the JavaScript defaultValue attribute."

This means that if the value attribute of this textarea is set, the reset button will restore the textarea to the value of this value attribute instead of being empty.

The conclusion is as follows:

Reset does not clear the value of the input box, but restores the value of the input box to the value specified by the value attribute.
This becomes clear after looking at the following example. Save the following HTML code as a .html file, open it with a browser, modify the content of the input box, and click the reset button to see the effect.

<form>
<input type="textarea" value="defaultValue"/>
<input type="reset" />
</form>

However, on the query result page, we sometimes hope that the value attribute has a value (the input condition of the last query), so we cannot use the reset tag to implement the clearing function, note that it is clearing.

The simulation method is as follows: use the button tag instead of the reset tag, and use js to set the value of the textarea to empty.

<<:  Summary of several submission methods of HTML forms

>>:  Example of implementing a seamless infinite loop of background using CSS animation

Recommend

What command is better for fuzzy searching files in Linux?

1. Introduction This article mainly explains how ...

js to realize payment countdown and return to the home page

Payment countdown to return to the home page case...

Summary of common commands for building ZooKeeper3.4 middleware under centos7

1. Download and decompress 1. Introduction to Zoo...

Correct steps to install Nginx in Linux

Preface If you are like me, as a hard-working Jav...

JavaScript implements the protocol example in which the user must check the box

In js, set the user to read a certain agreement b...

Solution to the problem of English letters not wrapping in Firefox

The layout of text has some formatting requiremen...

How to solve the slow speed of MySQL Like fuzzy query

Question: Although the index has been created, wh...

MySQL foreign key constraint (FOREIGN KEY) case explanation

MySQL foreign key constraint (FOREIGN KEY) is a s...

Detailed explanation of selinux basic configuration tutorial in Linux

selinux ( Security-Enhanced Linux) is a Linux ker...

How much data can be stored in a MySQL table?

Programmers must deal with MySQL a lot, and it ca...

Detailed explanation of two quick ways to write console.log in vscode

(I) Method 1: Define it in advance directly in th...

HTML marquee tag usage examples

This tag is not part of HTML3.2 and only supports ...

Detailed steps to install Hadoop cluster under Linux

Table of contents 1. Create a Hadoop directory in...