How to prevent user from deleting text in a text box

泪湿孤枕 提交于 2019-12-24 09:43:53

问题


Ok so I am new here and was wondering if someone a little more advance then me can help me out.

I have text box on my website with code for user(s) to copy the code that's in the text box and paste the code in Orkut scrapbook which will generate a imagine.

I am using onclick so when user clicks on code it highlight it and then they can copy.

The problems is that you can delete or remove text from within box, if your not careful.

I DONT want the user to be able to delete code in text box. How can I prevent this from happening without removing the onclick scrip.

Please if you could when reply maybe include the sample code above and highlight the new added code so I can see where to make my changes.

I hope I explained this well for anyone to understand!


回答1:


You can add readonly="readonly" to your textbox tag. Example:

<input type="text" name="someNAme"  readonly="readonly" >

you can also try with:

<input type="text" name="someNAme"  disabled="disabled" >


来源:https://stackoverflow.com/questions/2266398/how-to-prevent-user-from-deleting-text-in-a-text-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!