开发者

making text boxes non editable in html

i am trying to make a text box no editable for the users. I tried using 开发者_如何转开发this code and it works. Any ramifications??? I mean do u suggest the use of this code or it may cause trouble for me in future???

<input type="text" name="west" value="fixed value" readonly />


you shouldnt have a problem with this code as the inputs value gets submitted along with any other inputs in the form.

Make sure that you validate this on the server side as someone could send a value you are not expecting via dev tools or tools like fiddler.

I would change it to have a value. e.g readonly="readonly" so that it is valid xhtml. The value of the readonly attribute is irrelevant and can therefore be any value.

All of the below are readonly

<input type="text" readonly="readonly" value="readonly" />
<input type="text" readonly="true"  value="true" />
<input type="text" readonly="monkey" value="monkey" />
<input type="text" readonly="false" value="false (still readonly)" />

input documentation


You must be aware that anybody can change this to something writable using a tool like firebug.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜