我将如何在一个只读字段的字段中写入。
以下是我的HTML代码:
<input id="detlSancOrderDt" class="false hasDatepicker" type="text" value="" readonly="readonly" style="width:100px;text-align:center;" name="detlSancOrderDt" autocomplete="off" tabindex="-1"></input>
答案 0 :(得分:1)
添加disabled
属性。
<input id="detlSancOrderDt" ... disabled="disabled"></input>
按照Erik Allik的评论编辑。
答案 1 :(得分:0)
希望您需要向用户显示该字段在rails中为readonly
。因此,如果您使用ERB
模板,则可以将上面给出的HTML转换为:
<%= text_field_tag "detlSancOrderDt", nil, class: 'false hasDatepicker', placeholder: 'This field is read only..', readonly: true, style: "width:100px;text-align:center;", autocomplete: "off", tabindex: "-1" %>
希望有所帮助:)
答案 2 :(得分:0)
此问题与ruby或rails无关。如果要更改readonly
文本字段中的值,请在浏览器控制台中检查文本字段并更改值。
Ex.in firefox
浏览器安装firebug
并按F12
并检查文本字段并更改值。