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®"> 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.
3) Adding the attribute onsubmit="return false"; to the form can also solve the problem.