How to disable backspace in browser?

Some it is necessary to disable backspace button in browser. This javascript code can help to disable backspace:

document.onkeydown = function () {
 var e = event || window.event;
 var keyASCII = parseInt(e.keyCode, 10);
 var src = e.srcElement;
 var tag = src.tagName.toUpperCase();
 if(keyASCII == 13) {
  return false;
 }
 if(keyASCII == 8) {
  if(src.readOnly || src.disabled || (tag != "INPUT" && tag != "TEXTAREA")) {
   return false;
  }
  if(src.type) {
   var type = ("" + src.type).toUpperCase();
   return type != "CHECKBOX" && type != "RADIO" && type != "BUTTON";
  }
 }
 return true;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

five × three =