handle backspace key
-
Hi, hi i am new in asp.net. I have problem that at the time of using website if i press backspace key then it shows the previous page, i want to an alert message if user press backspace key at the time using website... thanks
-
Hi, hi i am new in asp.net. I have problem that at the time of using website if i press backspace key then it shows the previous page, i want to an alert message if user press backspace key at the time using website... thanks
-
Use the following JS function
function checkBackSpace()
{
if(event.keyCode==8)
{
alert('You pressed BackSpace');
return false;
}
}and put it on body tag as
Now you will get a message.
Cheers!! Brij
I think Brij is right. But a little changes are required in this code. Otherwise it will alert when user hits backspace key in a textbox. So here is the answer below In JS code --------------------- function checkBackSpace(event) { event = event || window.event; var target = event.target || event.srcElement; if(event.keyCode==8 && (!(target.type =="text" || target.type =="textarea")) { alert('You pressed BackSpace'); return false; } return true; } and put it on body tag as ------------------------------- <body onkeydown="return checkBackSpace(event);> Cheers Prosanta
-
I think Brij is right. But a little changes are required in this code. Otherwise it will alert when user hits backspace key in a textbox. So here is the answer below In JS code --------------------- function checkBackSpace(event) { event = event || window.event; var target = event.target || event.srcElement; if(event.keyCode==8 && (!(target.type =="text" || target.type =="textarea")) { alert('You pressed BackSpace'); return false; } return true; } and put it on body tag as ------------------------------- <body onkeydown="return checkBackSpace(event);> Cheers Prosanta
-
:) thanks a lot you both Brij and Prosanta...
-
:) thanks a lot you both Brij and Prosanta...
hi its working but there is some error when i navigating using tab key.... it throughs error related object... why? how i handle it?
-
hi its working but there is some error when i navigating using tab key.... it throughs error related object... why? how i handle it?
Hi here is your code below function checkBackSpace(event) { event = event || window.event; var target = event.target || event.srcElement; if(event.keyCode==8) { if((!(target.type =="text" || target.type =="textarea")) { alert('You pressed BackSpace'); return false; } } return true; } Cheers Prosanta