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)

Recommend

Summary of some common writing methods that cause MySQL index failure

Preface Recently, I have been busy dealing with s...

7 ways to vertically center elements with CSS

【1】Know the width and height of the centered elem...

Detailed steps for deploying Tomcat server based on IDEA

Table of contents Introduction Step 1 Step 2: Cre...

Example code for css flex layout with automatic line wrapping

To create a flex container, simply add a display:...

mysql5.6.8 source code installation process

Kernel: [root@opop ~]# cat /etc/centos-release Ce...

How to solve the abnormal error ERROR: 2002 in mysql

Recently, an error occurred while starting MySQL....

A brief analysis of the knowledge points of exporting and importing MySQL data

Often, we may need to export local database data ...

Common commands for mysql authorization, startup, and service startup

1. Four startup methods: 1.mysqld Start mysql ser...

Move MySQL database to another disk under Windows

Preface Today I installed MySQL and found that th...

Detailed explanation of the steps to build a Vue project with Vue-cli

First you need to install Vue-cli: npm install -g...

Windows Server 2008 Tutorial on Monitoring Server Performance

Next, we will learn how to monitor server perform...

Detailed configuration of wireless network card under Ubuntu Server

1. Insert the wireless network card and use the c...

MySQL query learning basic query operations

Preface MySQL is the most popular relational data...