Press Enter to automatically submit the form. Unexpected discovery

Press Enter to automatically submit the form. Unexpected discovery

Copy code
The code is as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="http://www.baidu.com">
<input type="text" name="name"/>
<input type="button" onclick="javascript:void(0)" value="Submit">
</form>
</body>
</html>

As shown in the above form, when you press Enter in the name input box, the form will be submitted. And there is no submit button in the form.

After much searching I finally found the reason: If there is only one text box in the form, the form will be submitted when you press Enter.

So the solution is easy, just add a useless text box and hide it.

Copy code
The code is as follows:

<input type="text" style='display:none' />

Note: It is not possible to add a hidden box.

Copy code
The code is as follows:

<input type="hidden" />

<<:  Solve the mysql problem: Unable to continue code execution because MSVCR120.dll is not found

>>:  CSS method of clearing float and BFC

Recommend

Tutorial on installing DAMO database on Centos7

1. Preparation After installing the Linux operati...

css Get all elements starting from the nth one

The specific code is as follows: <div id="...

How to add ansible service in alpine image

Use apk add ansible to add the ansible service to...

IE8 provides a good experience: Activities

Today I had a sneak peek at IE8 beta 1 (hereafter...

The linkage method between menu and tab of vue+iview

Vue+iview menu and tab linkage I am currently dev...

Pure CSS to achieve the list pull-down effect in the page

You may often see the following effect: That’s ri...

Solve the Linux Tensorflow2.0 installation problem

conda update conda pip install tf-nightly-gpu-2.0...

Sitemesh tutorial - page decoration technology principles and applications

1. Basic Concepts 1. Sitemesh is a page decoratio...

Detailed explanation of when javascript scripts will be executed

JavaScript scripts can be embedded anywhere in HT...