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

zabbix custom monitoring nginx status implementation process

Table of contents Zabbix custom monitoring nginx ...

Mysql master-slave synchronization Last_IO_Errno:1236 error solution

What is the reason for the Last_IO_Errno:1236 err...

SQL Server Comment Shortcut Key Operation

Batch comments in SQL Server Batch Annotation Ctr...

What is BFC? How to clear floats using CSS pseudo elements

BFC Concept: The block formatting context is an i...

React Hooks Common Use Scenarios (Summary)

Table of contents 1. State Hook 1. Basic usage 2....

MySQL 8.0.13 download and installation tutorial with pictures and text

MySQL is the most commonly used database. You mus...

Detailed explanation of the use of the clip-path property in CSS

Use of clip-path polygon The value is composed of...

Three examples of nodejs methods to obtain form data

Preface Nodejs is a server-side language. During ...

Vue implements book management case

This article example shares the specific code of ...

Example of how to create a database name with special characters in MySQL

Preface This article explains how to create a dat...

How to prevent Vue from flashing in small projects

Summary HTML: element plus v-cloak CSS: [v-cloak]...

Detailed steps to install Docker mongoDB 4.2.1 and collect springboot logs

1: Install mongodb in docker Step 1: Install mong...