document.onkeydown =function (e) { var code,type; if (!e){ var e = window.event;} if (e.keyCode){ code = e.keyCode;} else if (e.which){ code = e.which;} type = event.srcElement.type; if ((code == 8) && ((type == "text" && type == "textarea" ) || event.srcElement.readOnly == true)) { event.keyCode = 0; event.returnValue = false; } return true; };