Comparison of use of form element attributes readonly and disabled_HTML/Xhtml_Web page production
- WBOYOriginal
- 2016-05-16 16:39:471393browse
1) Scope of application:
readonly: input[type="text"],input[type="password"],input[type="teaxtarea"]
disabled: all forms Elements, such as select, radio, checkbox, button, etc.
2) Operation:
readonly: Users are not allowed to modify the operation and do not affect any other operations
disabled: blocked All user operations, including user click events and focus events
3) Form submission:
readonly: The values of form elements can be submitted to the server.
disabled: The value of the form element will not be submitted to the server, that is, the server cannot obtain the value in this form element
Common applications:
a> A unique identification code is prefilled for the user in a form and is not allowed to be changed by the user. However, the value needs to be passed when submitting. At this time, its attribute should be set to readonly;
b>Prevent repeated submission of the form. Use javascript to disable the submit button (form button) after submitting the form.
c>Set read-only in checkbox and radio: disable default events
For example: bind("click",function(){return false;}) in jquery;
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