Sometimes it's hard to use a read-only text box, can be found today, read-only text box has a flaw, when the mouse focus in the text box when the Back button (BackSpace), will be back to the previous page, the problem is a bit annoying, the user is not clear can input, If he sees a text box that wants to change something in it, click on it, and it's possible that all the data you've filled out will be lost. So write a method for everyone to put in <script></script> when needed;
Copy Code code as follows:
Document.documentElement.onkeydown = function (evt) {
var b =!! EVT, oevent = evt | | window.event;
if (Oevent.keycode = = 8) {
var node = b? OEvent.target:oEvent.srcElement;
var reg =/^ (Input|textarea) $/i, Regtype =/^ (Text|textarea) $/i;
if (!reg.test (node.nodename) | | |!regtype.test (node.type) | | node.readonly | | node.disabled) {
if (b)
{
Oevent.stoppropagation ();
}
Else
{
Oevent.cancelbubble = true;
Oevent.keycode = 0;
Oevent.returnvalue = false;
}
}
}
}