新闻动态

良好的口碑是企业发展的动力

htmlreadonly

发布时间:2023-11-15 08:48:20 点击量:131
免费建站模板

 

HTML Readonly

 

HTML Readonly Attribute

 

The readonly attribute specifies that an input field is read-only (not editable).

 

Syntax:

<input readonly="readonly" />

 

The attribute is added to the <input> element to make it read-only. The value of the readonly attribute is set to "readonly".

 

Example:

<input type="text" readonly="readonly" value="This input field is read-only." />

 

In the above example

the <input> element with the type set to "text" is made read-only using the readonly attribute. The value attribute is used to set the initial value of the input field.

 

When a form is submitted

the data in a read-only input field is sent to the server

just like any other input field. However

since the field is read-only

the user cannot modify the value before submitting the form.

 

If you want to prevent the data in the input field from being sent to the server

you can use the disabled attribute instead. The disabled attribute also makes the input field uneditable

but it does not submit the data when the form is submitted.

 

Note: The readonly attribute is only valid for the <input> element and its variations (e.g.

<input type="text">

<input type="password">

etc.).

 

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:dm@cn86.cn进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。本站原创内容未经允许不得转载。