Tangled up the day, and finally the correct use of the HTML tags, the applicability of their respective clearly understood, here is a simple summary to avoid making similar mistakes.
It's all because of a problem like this
To run the above code, when nothing is entered when the "Login" button, will prompt "user name can not be empty", but only a moment will flash back. What is the reason?
The point is here.
At this point there will be two events triggered, first call the onclick corresponding function, and then automatic submit (because the type is a submit at this time), will naturally overwrite the hint. So the type is set to a button to resolve.
Here's a quick summary,
HtmlThe Type property of the label
value |
Description |
button |
Define clickable buttons ( in most cases, use JavaScript to launch scripts ). |
CheckBox |
Define the check box. |
File |
Define input fields and "Browse" buttons for file uploads. |
Hidden |
Defines the hidden input field. |
Image |
Defines the submit button in the form of an image. |
Password |
Defines the password field. The characters in the field are masked. |
Radio |
Defines a radio button. |
Reset |
Defines the reset button. The reset button clears all the data from the form. |
Submit |
Define the Submit button. The submit button sends the form data to the server. |
Text |
Defines an input field for a single line in which the user can enter text. The default width is 20 characters. |
Note: Type=button: simply a button function; Type=submit: Send form .
HTML label Type property
value |
Description |
Submit |
The button is a Submit button (except Internet Explorer, which is the default value for other browsers). |
button |
the button is a clickable button (the default value for Internet Explorer). |
Reset |
the button is the reset button (clears the form data). |
not finished ...
Copyright notice: This article is a blogger original article, not allowed to be reproduced without the permission of Bo master.
Above describes the HTML tags easy to mix and error small summary, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.