|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Disable Backspace
Hi,
Just a quicky how can i disable the backspace. I have found code for the enter key but dont understand it. So any help will be great thanks <script language="JavaScript" type="text/javascript"> function checkCR(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if ((evt.keyCode == 13) && (node.type=="text")) {return false;} } document.onkeypress = checkCR; </script> Tnx Adz |
|
#2
|
||||
|
||||
|
The question that needs to be answered first is why would you want to do that?
__________________
Vladdy Working web site is not the one that looks the same in a few graphical browsers, but the one that adequately delivers its content to any device accessing it. |
|
#3
|
|||
|
|||
|
The reason why is because, at work our agents use webscript and on the web script there is an ocx, but when you press back space it goes back a page and i cant do anything about it.
So the best way is to disable backspace on that page. Thanks Adam |
|
#4
|
||||
|
||||
|
Get ASCII chart, lookup code for "Backspace" and replace 13 with it.
__________________
Vladdy Working web site is not the one that looks the same in a few graphical browsers, but the one that adequately delivers its content to any device accessing it. |
|
#6
|
||||
|
||||
|
Then, I guess, the browser catches the event before it is passed to the page, which means you are out of luck.
__________________
Vladdy Working web site is not the one that looks the same in a few graphical browsers, but the one that adequately delivers its content to any device accessing it. |
|
#7
|
||||
|
||||
|
Maybe try listening for it onkeydown instead of onkeypress. You might be able to catch the event that way.
|
|
#8
|
||||
|
||||
|
Try This:
<script type="text/javascript"> if (typeof window.event != 'undefined') document.onkeydown = function() { if (event.srcElement.tagName.toUpperCase() != 'INPUT') return (event.keyCode != 8); } else document.onkeypress = function(e) { if (e.target.nodeName.toUpperCase() != 'INPUT') return (e.keyCode != 8); } </script> |
|
#9
|
|||
|
|||
|
You don't know how long I have been looking for some code that would work on a data access page....THIS DOES! Thanks
|
|
#10
|
||||
|
||||
|
Wow, I forgot I was still submitted to get a reply to this 2 year old thread.
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|