Home>Article>Web Front-end> How to make html input non-editable

How to make html input non-editable

藏色散人
藏色散人 Original
2021-06-03 10:38:58 5549browse

html How to set the input to be non-editable: 1. Use the disabled attribute to specify that the input element is disabled; 2. Use the readonly attribute to specify that the input field is read-only and copyable; 3. Implement it through "readonly unselectable="on"" Not editable.

How to make html input non-editable

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

3 ways to make the input text box uneditable

Today I tried 3 ways to make the input text box uneditable. Now I’ll summarize:

  • The disabled attribute stipulates 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.

Example:

  • ##readonly attribute specifies that the input field is read-only Copyable, however, the user can use the Tab key to switch to the field, be selectable, receive focus, and 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 or .

Example:

    ##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: (I am still a novice, please correct me if I write something wrong!)
  • [Recommended learning:
html video tutorial

The above is the detailed content of How to make html input 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
Previous article:How to write spaces in html Next article:How to write spaces in html