The difference between Readonly and Disabled

The difference between Readonly and Disabled
To summarize:
Readonly is only valid for input (text / password) and textarea, while disabled is valid for all form elements, including select, radio, checkbox, button, etc. However, after using disabled for a form element, when we submit the form via POST or GET, the value of this element will not be passed out, while readonly will pass the value out (this situation occurs when we set the textarea element in a form to disabled or readonly, but the submit button can be used).
The more common situations are:
① In a form, a unique identification code is pre-filled for the user, and the user is not allowed to change it. However, the value needs to be passed when submitting. In this case, its attribute should be set to readonly
② It is often encountered that after the user formally submits the form, he needs to wait for the administrator to verify the information. This does not allow the user to change the data in the form, but can only view it. Since disabled has a wide range of elements, disabled should be used at this time. However, it should be noted that the submit button should also be disabled. Otherwise, as long as the user presses this button, if no integrity check is performed on the database operation page, the value in the database will be cleared. If readonly is used instead of disabled in this case, it is still OK if there are only input (text/password) and textarea elements in the form. If there are other elements, such as select, the user can rewrite the value and press the Enter key to submit (Enter is the default submit trigger key)
③We often use JavaScript to disable the submit button after the user presses it. This can prevent the user from repeatedly clicking the submit button in an environment with poor network conditions, causing data to be redundantly stored in the database.

<<:  mysql8.0.23 msi installation super detailed tutorial

>>:  Installing Alibaba Cloud Server with Docker and the pitfalls encountered in installing it in a virtual machine (summary of problems)

Blog    

Recommend

Detailed explanation of Nginx configuration required for front-end

Nginx (engine x) is a lightweight, high-performan...

Tutorial on logging into MySQL after installing Mysql 5.7.17

The installation of mysql-5.7.17 is introduced be...

The pitfalls encountered when learning Vue.js

Table of contents Class void pointing ES6 Arrow F...

A brief comparison of Props in React

Table of contents Props comparison of class compo...

How to run commands on a remote Linux system via SSH

Sometimes we may need to run some commands on a r...

Implementation of Docker Compose multi-container deployment

Table of contents 1. WordPress deployment 1. Prep...

Chrome monitors cookie changes and assigns values

The following code introduces Chrome's monito...

Steps to install MySQL using Docker under Linux

As a tester, you may often need to install some s...

Detailed explanation of the use of custom parameters in MySQL

MySQL variables include system variables and syst...

Uncommon but useful tags in Xhtml

Xhtml has many tags that are not commonly used but...

Sample code for implementing neon button animation effects with CSS3.0

Today I will share with you a neon button animati...

Detailed tutorial on installing pxc cluster with docker

Table of contents Preface Preliminary preparation...