问题描述
好吧,所以我是新来的,想知道是否有人比我先进一些可以帮助我.
Ok so I am new here and was wondering if someone a little more advance then me can help me out.
我的网站上有一个文本框,上面有用于用户的代码,用于复制文本框中的代码,并将代码粘贴到Orkut剪贴簿中,这将产生一个想象.
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.
我正在使用onclick,因此当用户单击代码时,它会突出显示它,然后他们就可以复制.
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.
我不希望用户能够删除文本框中的代码.如何在不删除onclick脚本的情况下防止这种情况的发生.
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!
推荐答案
您可以将readonly ="readonly"添加到文本框标记中.示例:
You can add readonly="readonly" to your textbox tag. Example:
<input type="text" name="someNAme" readonly="readonly" >
您也可以尝试:
<input type="text" name="someNAme" disabled="disabled" >
这篇关于如何防止用户删除文本框中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!