The difference between readonly and disabled


The summary is as follows:
Readonly is valid only for input (text / password) and textarea, while disabled is valid for all form elements, including select, radio, checkbox, button, etc. However, after the form element is disabled, when we submit the form in the form of post or get, the value of this element will not be passed, but readonly will pass the value (this occurs when we set the textarea element in a form to disabled or readonly, but the submit button can be used).
The common situations are:
① A unique identification code is pre filled for the user in a form, and the user is not allowed to change it. However, the value needs to be passed when submitting. At this time, its attribute should be set to readonly
② It is often encountered that the user needs to wait for the information verification of the administrator after formally submitting the form, which does not allow the user to change the data in the form, but can only view it. Because the scope of disabled elements is large, disabled should be used at this time, but at the same time, it should be noted that the submit button should also be disabled, otherwise as long as the user presses this button, If integrity detection is not performed in the database operation page, the values in the database will be cleared. In this case, if you use readonly instead of disabled, if the form has only input (text / password) and textarea elements, it is still OK. If there are other sending elements, such as select, the user can press enter after rewriting the value to submit (enter is the default submit trigger button)
③ We often use JavaScript to disable the submit button after the user presses the submit button, which can prevent the user from repeatedly clicking the submit button in the environment with poor network conditions, resulting in redundant data storage in the database.

Recommended Today

Apache sqoop

Source: dark horse big data 1.png From the standpoint of Apache, data flow can be divided into data import and export: Import: data import. RDBMS—–>Hadoop Export: data export. Hadoop—->RDBMS 1.2 sqoop installation The prerequisite for installing sqoop is that you already have a Java and Hadoop environment. Latest stable version: 1.4.6 Download the sqoop installation […]