Home>Article>Web Front-end> How to set read-only in html

How to set read-only in html

藏色散人
藏色散人 Original
2021-04-09 10:27:24 2944browse

htmlHow to set read-only: First create an HTML sample file; then create a form; then set the input tag; finally add the "readonly" attribute to the input tag to achieve the read-only effect.

How to set read-only in html

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

The readonly attribute specifies that the input field is read-only.

Read-only fields cannot be modified. However, users can still tab to the field and select or copy its text.

The readonly attribute prevents users from modifying the value until certain conditions are met (such as a checkbox being selected). Then, you need to use JavaScript to eliminate the readonly value and switch the input field to an editable state.

The readonly attribute can be used withor.

Syntax

Example:

HTML form with two text fields and a submit button:

  

Name:

Country:

请在提交按钮上单击,输入会发送到服务器上名为 "form_action.asp" 的页面。

Running effect:

How to set read-only in html

【Recommended learning:HTML video tutorial

The above is the detailed content of How to set read-only 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
Previous article:What are css properties Next article:What are css properties