Readonly and Disabled _ HTML/Xhtml _ webpage Creation
Source: Internet
Author: User
Readonly and Disabled are two attributes used in a form. They both enable users not to change the content in the form field. However, there are slight differences between them. I have summarized some rules in practice as follows:
Readonly is only valid for input (text/password) and textarea, while disabled is valid for all form elements, including select, radio, checkbox, And button. However, after a form element is disabled, when we submit the form in POST or GET mode, the value of this element will not be passed out, readonly will pass this value out (this occurs when we set the textarea element in a form to disabled or readonly, but the submit button is usable ).
Generally, the following situations are commonly used:
① A unique recognition code is pre-filled for the user in a form and cannot be modified by the user. However, this value must be passed during submission. In this case, set its attribute to readonly.
② Users often need to wait for the Administrator to verify the information after submitting the form. This does not allow users to change the data in the form, but can only view the data. Due to the wide scope of the disabled element, therefore, you should use disabled at this time, but note that the submit button should also be disabled. Otherwise, if the user presses this button, if the database operation page does not perform Integrity Detection, the value in the database is cleared. In this case, if we use readonly to replace disabled, we can still use only the input (text/password) and textarea elements in the form. If there are other sending elements, such as select, you can press the Enter key to submit the changes (Press enter as the default submit trigger button)
③ After the user presses the submit button, the submit button is disabled using javascript, which can prevent poor network conditions, the user repeatedly clicks the submit button, causing redundant data to be stored in the database.
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service