I am trying to prevent the backspace key from going to the previous page. I have Javascript code to prevent that, and it works... Unless the focus is inside of the textbox element. The problem is that the particular textbox is Read-Only. If I remove the Read-Only attribute, then all is well, I can press backspace all I want with the focus in the textbox and it will not go to the previous page, but I need the attribute set.
Below is the code preventing the backspace key from going to the previous page, but allowing it to be used inside of Non Read-Only input fields.
$(document).keydown(function (e) {
if (e.keyCode == 8 && e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
e.preventDefault();
}
});
The expected outcome is to be able to focus the Read-Only textbox, and press the backspace key and the application NOT go back to the previous page.