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

MySQL 8.0.20 installation and configuration tutorial under Win10

MySQL 8.0.20 installation and configuration super...

MySQL 8.0.22 installation and configuration graphic tutorial

MySQL8.0.22 installation and configuration (super...

Calendar effect based on jQuery

This article example shares the specific code of ...

From CSS 3D to spatial coordinate axis with source code

One time we talked about the dice rolling game. A...

jQuery implements a simple carousel effect

Hello everyone, today I will share with you the i...

Optimal web page width and its compatible implementation method

1. When designing a web page, determining the widt...

The correct way to use Homebrew in Linux

Many people use Linux Homebrew. Here are three ti...

The difference between absolute path and relative path in web page creation

1. Absolute path First of all, on the local compu...

Execution context and execution stack example explanation in JavaScript

JavaScript - Principles Series In daily developme...

img usemap attribute China map link

HTML img tag: defines an image to be introduced in...

Some notes on mysql create routine permissions

1. If the user has the create routine permission,...