How to remove the "Enter" in the form, "Submit" and "Enter != Submit"

How to remove the "Enter" in the form, "Submit" and "Enter != Submit"
To implement the "Enter != Submit" problem, you can generally start from the "button type" and "number of input boxes".

By default, for a single input box, regardless of whether the button is type="submit" or type="button", pressing Enter means submitting.

1. When type="submit", no matter how many type="text" input boxes there are, pressing Enter means submit. (submit)

2. When type="button" and there are multiple input boxes, pressing Enter does not submit. (button)

3. To solve the problem of submitting when pressing Enter in a single input box, refer to the second point: you can add an input="text" and hide it; then set the type to button.

In actual applications, there is rarely only one input box, so you only need to remember the second rule to deal with it.

Using JS events to prevent form submission is beyond the scope of this article, but it is certainly possible.

<<:  How to use docker compose to build fastDFS file server

>>:  9 super practical CSS tips to help designers and developers

Recommend

Vue implements DingTalk's attendance calendar

This article shares the specific code of Vue to i...

js to achieve interesting countdown effect

js interesting countdown case, for your reference...

Implementing simple chat room dialogue based on websocket

This article shares the specific code for impleme...

How to wrap HTML title attribute

When I was writing a program a few days ago, I wan...

svg+css or js to create tick animation effect

Previously, my boss asked me to make a program th...

Detailed explanation of mysql trigger example

Table of contents What is a trigger Create a trig...

Docker installation steps for Redmine

Download the image (optional step, if omitted, it...

Tutorial on how to modify the root password in MySQL 5.7

Version update, the password field in the origina...

Blog Design Web Design Debut

The first web page I designed is as follows: I ha...

Are you still Select *?

There are many reasons why an application is as s...

Set an icon for the website to be displayed on the far left of the browser tab

What is the purpose of this sentence? Copy code Th...

How to restore a single database or table in MySQL and possible pitfalls

Preface: The most commonly used MySQL logical bac...

Start nginxssl configuration based on docker

Prerequisites A cloud server (centOS of Alibaba C...

Vue Router loads different components according to background data

Table of contents Requirements encountered in act...