How to set input in html to be non-editable

青灯夜游
Release: 2023-01-05 16:13:22
Original
8020 people have browsed it

Methods to set non-editable settings: 1. Add the "disabled="disabled"" statement to the input; 2. Add the "readonly="readonly"" statement to the input; 3. Add "readonly unselectable=" to the input. on"" statement.

How to set input in html to be non-editable

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

3 ways to make the input text box uneditable

1. disabled attribute

The disabled attribute specifies that the input element should be disabled. A disabled input element cannot be edited, copied, selected, cannot receive focus, and the background will not receive passed values. After setting, the color of the text will turn gray. The disabled attribute cannot be used with <input type="hidden">.

Example:

<input type="text" disabled="disabled" />
Copy after login

2. readonly attribute

readonly attribute specifies that the input field is read-only and copyable, but the user can use the Tab key to switch The field can be selected, can receive focus, and can select or copy its text. The passed value will be received in the background. The readonly attribute prevents users from modifying the value. The

readonly attribute can be used with <input type="text"> or <input type="password">.

Example:

<input type="text" readonly="readonly">
Copy after login

3. readonly unselectable="on"

readonly unselectable="on" This attribute is similar to disable, input element, It cannot be edited, copied, selected, and cannot receive focus. After setting, the color of the text will also turn gray, but the passed value can be received in the background.

Example:

<input type="text"  readonly  unselectable="on" >
Copy after login

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to set input in html to be non-editable. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!