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

harborRestart operation after modifying the configuration file

I won't say much nonsense, let's just loo...

A brief understanding of the difference between MySQL union all and union

Union is a union operation on the data, excluding...

MySQL Practical Experience of Using Insert Statement

Table of contents 1. Several syntaxes of Insert 1...

Vue-cli creates a project and analyzes the project structure

Table of contents 1. Enter a directory and create...

Docker deployment of Kafka and Spring Kafka implementation

This article mainly introduces the deployment of ...

React Hooks Usage Examples

Table of contents A simple component example More...

How to use VIM editor in Linux

As a powerful editor with rich options, Vim is lo...

Mybatis implements SQL query interception and modification details

Preface One of the functions of an interceptor is...

Have you really learned MySQL connection query?

1. Inner Join Query Overview Inner join is a very...

Summary of H5 wake-up APP implementation methods and points for attention

Table of contents Preface Jump to APP method URL ...

How to solve the problem of automatic package update in Debian system

I don't know when it started, but every time ...

How to make React components full screen

introduce This article is based on React + antd t...