I'm trying to capture and prevent the Backspace keypress from sending the Browser back, when a user is in a form, as some have lost the data they've entered after pressing backspace.
However, I need to allow it when I'm in a form field. The code I'm using so far is successfully preventing the Backspace, but in all circumstances:
Is there some way that I could use target property of the event, and determine if the target's parent is a form?
MTIA
Max Hugen
Australia
However, I need to allow it when I'm in a form field. The code I'm using so far is successfully preventing the Backspace, but in all circumstances:
Code:
function CancelBackspace(e) {
var keyPressed = (e.which)?e.which:window.event.keyCode;
return (keyPressed==8)?false:true;
}
<body onkeydown="return CancelBackspace(event)">
Is there some way that I could use target property of the event, and determine if the target's parent is a form?
MTIA
Max Hugen
Australia