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

Implementation of Docker private warehouse registry deployment

As more and more Docker images are used, there ne...

Detailed explanation of CocosCreator MVC architecture

Overview This article will introduce the MVC arch...

Summary of methods to clear cache in Linux system

1) Introduction to cache mechanism In the Linux s...

CSS3 border effects

What is CSS# CSS (abbreviation of Cascading Style...

HTML drag and drop function implementation code

Based on Vue The core idea of ​​this function is ...

How to run Linux commands in the background

Normally, when you run a command in the terminal,...

How does the composite index of MySQL take effect?

Table of contents background Understanding compos...

Example of converting webpack images to base64

Download url-loader yarn add -D url-loader module...

Mysql uses insert to insert multiple records to add data in batches

If you want to insert 5 records into table1, the ...

Example code for implementing dynamic skinning with vue+element

Sometimes the theme of a project cannot satisfy e...