Home > Web Front-end > HTML Tutorial > 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.

高洛峰
Release: 2017-03-10 13:15:34
Original
2590 people have browsed it

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!

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