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

Details on how to write react in a vue project

We can create jsx/tsx files directly The project ...

Detailed tutorial on installing Prometheus with Docker

Table of contents 1. Install Node Exporter 2. Ins...

Native js to achieve accordion effect

In actual web page development, accordions also a...

How to create a stored procedure in MySQL and add records in a loop

This article uses an example to describe how to c...

How to modify the default submission method of the form

The default submission method of html is get inste...

Element UI table realizes drop-down filtering function

This article example shares the specific code for...

How to create a my.ini file in the MySQL 5.7.19 installation directory

In the previous article, I introduced the detaile...

CSS3 countdown effect

Achieve results Implementation Code html <div ...

HTML web page hyperlink tag

HTML web page hyperlink tag learning tutorial lin...

CentOS6.8 Chinese/English environment switching tutorial diagram

1. Introduction People who are not used to Englis...

jQuery realizes the full function of shopping cart

This article shares the specific code of jQuery t...

Detailed explanation of two ways to dynamically change CSS styles in react

The first method: dynamically add a class to show...

MySQL decimal unsigned update negative numbers converted to 0

Today, when verifying the concurrency problem of ...

Linux uses iptables to limit multiple IPs from accessing your server

Preface In the Linux kernel, netfilter is a subsy...