After struggling for a day, I finally have a clear understanding of the correct use of HTML tags and their respective applicability. Here is a brief summary to avoid making similar mistakes again.
Everything is due to such a problem
<html> <head> </head> <body> <form id="form1" method="get" > 用户名:<input type="text" id="name" name="name" /> <p id="username"></p> <br /> 密码:<input type="password" id="password" name="password" /> <button type="submit" /button> </form> <script> window.x=document.getElementById("username"); window. { document.getElementById('name').focus(); } // function mUp() { if(document.getElementById('name').value=="") { x.innerHTML = "用户名不能为空"; //alert("不能为空"); } else document.getElementById('form1').action="/login"; } </script> </body> </html>
The key is that there will be two events triggered by
<button type="submit" /button>
The following is a brief summary,
HTML tag's type attribute
value | description |
---|---|
button | defines clickable buttons (In most cases, used through JavaScript startup script ). |
checkbox | Define checkboxes. |
file | Define input fields and "Browse" button for file upload. |
hidden | Define hidden input fields. |
image | Define the submit button in the form of an image. |
password | Define the password field. Characters in this field are masked. |
radio | Define radio buttons. |
reset | Define the reset button. The reset button clears all data in the form. |
submit | Define the submit button. The submit button will send the form data to the server. |
text | Define a single-line input field where the user can enter text. The default width is 20 characters. |
button
This button is a clickable button (default for Internet Explorer).
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission. | |