HTML 输入框 - 禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/372604/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:53:45  来源:igfitidea点击:

HTML Input Box - Disable

htmlinput

提问by David Bonnici

what is the code to disable an INPUT text box for HTML?

禁用 HTML 的 INPUT 文本框的代码是什么?

Thanks

谢谢

回答by Greg

<input type="text" disabled="disabled" />

See the W3C HTML Specification on the input tagfor more information.

有关更多信息,请参阅输入标签上W3C HTML 规范

回答by kiruba

<input type="text" required="true" value="" readonly="true">

This will make a text box in readonly mode, might be helpful in generating passwords and datepickers.

这将使文本框处于只读模式,可能有助于生成密码和日期选择器。

回答by fasih.rana

The syntax to disable an HTML input is as follows:

禁用 HTML 输入的语法如下:

<input type="text" id="input_id" DISABLED />

回答by sjsupersumit

You can Use both disabled or readonly attribute of input . Using disable attribute will omit that value at form submit, so if you want that values at submit event make them readonly instead of disable.

您可以同时使用 input 的 disabled 或 readonly 属性。使用 disable 属性将在表单提交时省略该值,因此如果您希望在提交事件中使用该值,请将它们设为只读而不是禁用。

<input type="text" readonly> 

or

或者

 <input type="text" disabled>

回答by Deep Sojitra

<input type="text" required="true" value="" readonly>

Not the.

不是。

<input type="text" required="true" value="" readonly="true">