HTML text box (text) is not available in multiple ways to achieve read-only

HTML text box (text) is not available in multiple ways to achieve read-only
Method 1: <input id= "File1" type= "text" disabled/> Unavailable Method 2: <input id= "File1" type= "text" readonly/> Read-only Method 3: <input id= "File1" type= "text" style="display:none"/> Hidden (but takes up space)
Method 4: <input id="File1" type="text" style="visibility:hidden"/> hidden (does not take up space)

Sometimes, we want the text boxes in the form to be read-only so that users cannot modify the information in them, such as making the content of <input type="text" name="input1" value="中国">, the word "中国" cannot be modified. To summarize, there are several ways to implement it.

Method 1: onfocus=this.blur()

Copy code
The code is as follows:

<input type="text" name="input1" value="中国" onfocus=this.blur()>

Method 2: readonly

Copy code
The code is as follows:

<input type="text" name="input1" value="中国" readonly>
<input type="text" name="input1" value="中国" readonly="true">

Method 3: disabled

Copy code
The code is as follows:

<input type="text" name="input1" value="中国" disabled>

<<:  MySQL Query Cache Graphical Explanation

>>:  Analysis of the problem of deploying vue project and configuring proxy in Nginx

Recommend

Solution for Nginx installation without generating sbin directory

Error description: 1. After installing Nginx (1.1...

Vue implements form data validation example code

Add rules to the el-form form: Define rules in da...

Detailed explanation of the watch listener example in vue3.0

Table of contents Preface The difference between ...

SQL ROW_NUMBER() and OVER() method case study

Syntax format: row_number() over(partition by gro...

CSS new feature contain controls page redrawing and rearrangement issues

Before introducing the new CSS property contain, ...

Detailed tutorial on installing Tomcat8.5 in Centos8.2 cloud server environment

Before installing Tomcat, install the JDK environ...

Solve the problem of using swiper plug-in in vue

Since I used this plugin when writing a demo and ...

Vue implements fuzzy query-Mysql database data

Table of contents 1. Demand 2. Implementation 3. ...

Installation and use of Apache stress testing tools

1. Download Go to the Apache official website htt...

Detailed discussion of the character order of mysql order by in (recommended)

//MySQL statement SELECT * FROM `MyTable` WHERE `...

Summary of Linux command methods to view used commands

There are many commands used in the system, so ho...

How to use js to determine whether a file is utf-8 encoded

Conventional solution Use FileReader to read the ...

The best 9 foreign free picture material websites

It is difficult to find good image material websi...