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

WBOY
Release: 2016-06-24 11:40:12
Original
1413 people have browsed it

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>
Copy after login

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.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!