Home  >  Article  >  Web Front-end  >  Problem with automatic submission of form form by pressing enter key_html/css_WEB-ITnose

Problem with automatic submission of form form by pressing enter key_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:40:121441browse

No more nonsense. Go directly to the code.

1: The form is automatically submitted by pressing the enter key

 1 <!doctype html> 2 <html lang="en"> 3  <head> 4   <meta charset="UTF-8"> 5   <meta name="Generator" content="EditPlus&reg;"> 6   <meta name="Author" content=""> 7   <meta name="Keywords" content=""> 8   <meta name="Description" content=""> 9   <title>Document</title>10  </head>11  <body>12   <form method="post" action="http:www.baidu.com">13         <input>14         <textarea name="text" cols="20" rows="5" />15   </form>16  </body>17 </html>

Press the enter key in this text box, and the page will automatically jump to Baidu search page.

2: Solution

 1) Remove the form. Then press the enter key in the text box and the automatic jump will not occur. (Not recommended)

 2) Add another hidden text box. The problem occurs because there is only one text box in the form. Therefore, adding a hidden text box can also solve the problem.

 c88c69661ab813e8e91ee0382bdec2a3

 3) Adding the attribute onsubmit="return false"; to the form can also solve the problem.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn