Home  >  Article  >  Web Front-end  >  An introduction to the method of making text boxes such as form input read-only and non-editable in HTML.

An introduction to the method of making text boxes such as form input read-only and non-editable in HTML.

高洛峰
高洛峰Original
2017-03-10 13:15:342550browse

This article explains how to make text boxes such as form input read-only and non-editable in HTML

Sometimes, we want the text boxes in the form to be read-only so that users cannot modify the information in them. If the content of the input text is used, the Chinese characters cannot be modified. Sometimes, we want the text box in the form to be read-only so that users cannot modify the information in it, such as making the content of , "China "The two words cannot be modified. To summarize, the implementation methods are as follows.

Method 1: onfocus=this.blur() Leave the focus when the mouse cannot be placed


Method 2: readonly



Method 3: disabled


Complete example:



disabled="true" This fruit text will become Gray and not editable.
readOnly="true" The text will not change color and is not editable

css shielded input:

There are two methods. First: disabled="disabled" is defined so that the disabled input element is neither available nor clickable. Second: readonly="readonly" read-only fields cannot be modified. However, users can still use the tab key to switch to the field and select or copy its text;

The above is the detailed content of An introduction to the method of making text boxes such as form input read-only and non-editable in HTML.. 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