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.
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" />
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">
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!