Introduction to html form control disabled attributes readonly VS disabled

Introduction to html form control disabled attributes readonly VS disabled

There are two ways to disable form submission in HTML, they are:

1. Add readonly='readonly' attribute to the control tag

2. Add disabled='disabled' attribute to the control tag

For example:

<input type="text" value="" readonly="readonly" /> 
<input type="text" value="" disabled="disabled" />

Both controls in the example are not editable. But they also have some differences!

From the literal meaning, we can know that a control with the readonly attribute is "read-only", while a control with the disabled attribute is "disabled". So what is the difference between them?

The user cannot modify the value of a read-only control (a control that uses the readonly attribute) with the mouse or keyboard, but the programmer can modify it with JavaScript. When the form is submitted, the name and value of the control will be submitted to the server, which means it is visible to the server.

Disabled controls (controls with the disabled attribute) cannot be modified by users with the mouse and keyboard, and are also invisible to the server. That is, their names and values ​​are not submitted to the server when the form is submitted. Of course, programmers can also use JavaScript to modify their values.

This is their difference. After knowing the difference, we should know when to use which method, and we must not be blind!

Summarize

This is the end of this article about the difference between html form control disabled attributes readonly VS disabled. For more relevant html readonly disabled content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Detailed explanation of JSON.parse and JSON.stringify usage

>>:  Metadata Extraction Example Analysis of MySQL and Oracle

Recommend

Hello dialog box design experience sharing

"What's wrong?" Unless you are accus...

Tutorial on compiling and installing MySQL 5.7.17 from source code on Mac

1. Download and unzip to: /Users/xiechunping/Soft...

CSS layout tutorial: How to achieve vertical centering

Preface I have been summarizing my front-end know...

Detailed tutorial on installation and configuration of nginx under Centos7

Note: The basic directory path for software insta...

How to Apply for Web Design Jobs

<br />Hello everyone! It’s my honor to chat ...

Mysql SQL statement operation to add or modify primary key

Add table fields alter table table1 add transacto...

Detailed tutorial on deploying Apollo custom environment with docker-compose

Table of contents What is the Apollo Configuratio...

CSS to achieve the image hovering mouse folding effect

CSS to achieve the image hovering mouse folding e...

How to implement checkbox & radio alignment

Not only do different browsers behave differently...

HTML table tag tutorial (26): cell tag

The attributes of the <TD> tag are used to ...

A brief introduction to the command line tool mycli for operating MySQL database

GitHub has all kinds of magic tools. Today I foun...

Steps to create your own YUM repository

To put it simply, the IP of the virtual machine u...

Detailed explanation of Tomcat's Server Options

1. Configuration By default, the first two are no...

Basic usage of wget command under Linux

Table of contents Preface 1. Download a single fi...