Specific usage of textarea's disabled and readonly attributes

Specific usage of textarea's disabled and readonly attributes

disabled definition and usage

The disabled attribute is a boolean attribute.

The disabled attribute specifies that the text area should be disabled.

A disabled text area is neither usable nor has text that is selectable (cannot be copied).

You can set the disabled property to restore user access to the text area until some condition is met (such as selecting a checkbox). You can then use JavaScript to remove the value of the disabled attribute to make the text area enabled.

Differences between HTML 4.01 and HTML5

none.

Differences between HTML and XHTML In XHTML, attribute minimization is prohibited and the disabled attribute must be defined as <textarea disabled="disabled">.

The disabled attribute indicates a disabled text area. In a disabled text area, the content cannot be modified and the value cannot be passed in the request.

<textarea disabled>
At 123WORDPRESS.COM you will learn how to make a website. We provide the most comprehensive web technology tutorials.
</textarea>

The difference between disabled and disabled = "disabled"

disabled = "disabled" is the XML standard writing method. If you want to maintain XML compatibility, you must write disabled = "disabled". If you do not use XHTML and do not care about the XML syntax, you can use it alone.

Note: In browsers other than Firefox, such as Chrome, <textarea disabled> can be selected and copied.

Readonly definition and usage

The readonly attribute is a boolean attribute.

The readonly attribute specifies that the text area is read-only.

In a read-only text area, the content cannot be modified, but the user can switch to the control by using the tab key and select or copy the content.

You can set the readonly attribute to restore user access to the text area until some condition is met (such as selecting a checkbox). You can then use JavaScript to remove the value of the readonly attribute to make the text area editable. The readonly attribute specifies that the text area is read-only. In a read-only text area, the content cannot be modified. Values ​​can be passed in the request.

The specific usage is as follows:

<textarea readonly="readonly">test1</textarea> 
<textarea rows="3" cols="20" disabled="disabled"> 
test2 
</textarea> 

Differences between HTML and XHTML In XHTML, attribute minimization is prohibited and the readonly attribute must be defined as <textarea readonly="readonly">.

<<:  The best way to solve the 1px border on mobile devices (recommended)

>>:  This article will show you the basics of JavaScript: deep copy and shallow copy

Recommend

A brief discussion on MySQL large table optimization solution

background The amount of new data in the business...

Windows 2019 Activation Tutorial (Office2019)

A few days ago, I found that the official version...

Three ways to create a gray effect on website images

I’ve always preferred grayscale images because I t...

Nginx configuration 80 port access 8080 and project name address method analysis

Tomcat accesses the project, usually ip + port + ...

Native js to achieve star twinkling effect

This article example shares the specific code of ...

React's transition from Class to Hooks

Table of contents ReactHooks Preface WhyHooks? Fo...

Detailed explanation of how to use join to optimize SQL in MySQL

0. Prepare relevant tables for the following test...

Detailed explanation of the correct use of the count function in MySQL

1. Description In MySQL, when we need to get the ...

The process of building and configuring the Git environment in Docker

Configure Git environment in Docker At work, I en...

Detailed explanation of box-sizing in CSS3 (content-box and border-box)

Box-sizing in CSS3 (content-box and border-box) T...

Detailed steps to change the default password when installing MySQL in Ubuntu

Step 1: Enter the directory: cd /etc/mysql, view ...