Comparison of the use of form element attributes readonly and disabled

Comparison of the use of form element attributes readonly and disabled
1) Scope of application:
readonly:input[type="text"],input[type="password"],input[type="teaxtarea"]
disabled: all form elements, such as select, radio, checkbox, button, etc.

2) Operation:
readonly: users are not allowed to modify the operation, and no other operations are affected
disabled: Prevents all user operations, including user 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 the form element will not be submitted to the server, that is, the server cannot obtain the value of this form element

Common applications:

a> In a form, a unique identification code is pre-filled for the user, and the user is not allowed to change it, but the value needs to be passed when submitting. In this case, its attribute should be set

is readonly;

b>Prevent duplicate submission of the form and use javascript to disable the submit button (form button) after submitting the form.

c>Set checkbox and radio to read-only: disable default events such as: bind("click",function(){return false;}) in jQuery;

<<:  4 ways to achieve a two-column layout with fixed left column and adaptive right column using CSS

>>:  Sample code for making desktop applications with vue + Electron

Recommend

Docker container time zone error issue

Table of contents background question Problem ana...

In-depth analysis of MySQL query interception

Table of contents 1. Query Optimization 1. MySQL ...

Specific use of nginx keepalive

The default request header of the http1.1 protoco...

Methods of adaptive web design (good access experience on mobile phones)

1. Add the viewport tag to the HTML header. At th...

Deep understanding of the mechanism of CSS background-blend-mode

This article is welcome to be shared and aggregat...

The top fixed div can be set to a semi-transparent effect

Copy code The code is as follows: <!DOCTYPE ht...

Summary of some points to note when registering Tomcat as a service

Here are some points to note when registering Tom...

Detailed explanation of nginx configuration file interpretation

The nginx configuration file is mainly divided in...

Docker deployment of Kafka and Spring Kafka implementation

This article mainly introduces the deployment of ...

Comprehensive understanding of html.css overflow

Comprehensive understanding of html.css overflow ...

Complete steps to install mysql5.7 on Mac (with pictures and text)

I recently used a Mac system and was preparing to...

Tutorial on how to modify the root password in MySQL 5.7

Version update, the password field in the origina...

Implementation of Docker CPU Limit

1. --cpu=<value> 1) Specify how much availa...

jQuery realizes the shuttle box effect

This article example shares the specific code of ...

Several ways to manually implement HMR in webpack

Table of contents 1. Introduction 2. GitHub 3. Ba...