Home >Web Front-end >HTML Tutorial >How to set input in html to be non-editable

How to set input in html to be non-editable

青灯夜游
青灯夜游Original
2021-05-04 09:28:408090browse

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 10a0c4c6fe334f1dd2642c4aa224944a.

Example:

<input type="text" disabled="disabled" />

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 23efcc05e98690ceeb219581933e4231 or 794332e4da1b97221ff0ba8bc66903c4.

Example:

<input type="text" readonly="readonly">

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" >

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!

Statement:
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