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

Example code for implementing the "plus sign" effect with CSS

To achieve the plus sign effect shown below: To a...

Serial and parallel operations in JavaScript

Table of contents 1. Introduction 2. es5 method 3...

Execution context and execution stack example explanation in JavaScript

JavaScript - Principles Series In daily developme...

How to pop up a temporary QQ dialog box to chat online without adding friends

In fact, this is very simple. We add an a tag to ...

MySQL 8.0.18 installation tutorial under Windows (illustration)

Download Download address: https://dev.mysql.com/...

Detailed explanation of nginx optimization in high concurrency scenarios

In daily operation and maintenance work, nginx se...

Summary of 6 solutions for implementing singleton mode in JS

Preface Today, I was reviewing the creational pat...

Tutorial diagram of installing CentOS and Qt in Vmware virtual machine

Vmware Installation Installing Packages Download ...

Mybatis mysql delete in operation can only delete the first data method

Bugs As shown in the figure, I started to copy th...

CenterOS7 installation and configuration environment jdk1.8 tutorial

1. Uninstall the JDK that comes with centeros fir...

File upload via HTML5 on mobile

Most of the time, plug-ins are used to upload fil...

MySQL Query Cache and Buffer Pool

1. Caches - Query Cache The following figure is p...