Home > Article > Web Front-end > How to solve the problem when the form automatically submits and jumps to other pages after pressing Enter in the web page?
This time I will show you how to solve the problem of automatically submitting the form and jumping to other pages after pressing Enter in the web page. Precautions Yes Which ones, the following are practical cases, let’s take a look.
The form is automatically submitted after pressing Enter on the web page, and runs to other pages.
There is a form of Query. I originally wanted to query it when I clicked the query, but the test result is that it runs when pressing Enter. Went to other pages.
<form action="notice.php" method="get"> ... <button type='button' onclick ="search_wj()" class="btn btn-ok">查询</button> </form>
Solution:
Add an onsubmit="search_wj();return false;" to the form
<form action="notice.php" onsubmit="search_wj();return false;" method="get"> ... <button type='button' onclick ="search_wj()" class="btn btn-ok">查询</button> </form>
I believe I saw it You have mastered the methods in these cases. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Related reading:
How to implement a simple calculator in HTML
Example of how to add attributes using style
The above is the detailed content of How to solve the problem when the form automatically submits and jumps to other pages after pressing Enter in the web page?. For more information, please follow other related articles on the PHP Chinese website!