Comparison between readonly and disabled of form Element attributes _ HTML/Xhtml _ webpage Creation
Source: Internet
Author: User
The readonly and disabled attributes of form elements are different in terms of scope, operation, form submission, and so on. If you are interested, you can refer to this article.
1) Scope of adaptation: Readonly: input [type = "text"], input [type = "password"], input [type = "teaxtarea"]
Disabled: All form elements, such as select, radio, checkbox, And button
2) operation: Readonly: users are not allowed to modify the operation, and other operations are not affected.
Disabled: blocks all user operations, including click events and focus events.
3) Form submission: Readonly: the value of the form element can be submitted to the server.
Disabled: the value of a form element is not submitted to the server, that is, the server cannot obtain the value of this form element.
Common applications:
A> a unique recognition code is pre-filled in for the user in a form, which cannot be modified by the user. However, this value must be passed during submission. In this case, set its attributes.
Readonly;
B> prevent repeated submission of forms. After submitting a form, use javascript to disable the submit button (Form button.
C> set read-only in checkbox and radio: Disable default events
For example, bind ("click", function () {return false ;}) in jquery ;});
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.