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

A brief talk about Mysql index and redis jump table

summary During the interview, when discussing abo...

MySQL: Data Integrity

Data integrity is divided into: entity integrity,...

MySQL restores data through binlog

Table of contents mysql log files binlog Binlog l...

What command is better for fuzzy searching files in Linux?

1. Introduction This article mainly explains how ...

Getting Started with Mysql--sql execution process

Table of contents 1. Process 2. Core Architecture...

Detailed explanation of BOM and DOM in JavaScript

Table of contents BOM (Browser Object Model) 1. W...

Detailed explanation of common methods of Vue development

Table of contents $nextTick() $forceUpdate() $set...

Summary of various methods of implementing article dividing line styles with CSS

This article summarizes various ways to implement...

A brief discussion on the semantics of HTML and some simple optimizations

1. What is semanticization? Explanation of Bing D...

How to successfully retrieve VMware Esxi root password after forgetting it

Prepare a CentOS6 installation disk (any version)...

Thoroughly understand JavaScript prototype and prototype chain

Table of contents Preface Laying the foundation p...

Detailed tutorial on installing mysql under Linux

1. Shut down the mysql service # service mysqld s...

How to change the website accessed by http to https in nginx

Table of contents 1. Background 2. Prerequisites ...