2 Replies Latest reply on Feb 27, 2007 4:02 PM by SymTsb

    Disable Backspace when in input text fields

      Im trying to find a way to disable the keyboard backspace button from going back a page in the site but allowing it to function as a character delete when needed for typing in an input text field of a form.
      Strangely this problem only occurs for about a minute after the page is opened....after that it then works correctly. You can see what I mean by accessing the site's contact page

      I have found two different sets of code to disable the Backspace completely, but this then means it doesn't work at all when wanting to delete in the text field.

      Method 1:

      <script type="text/javascript">

      if (typeof window.event != 'undefined')
      document.onkeydown = function()
      if (event.srcElement.tagName.toUpperCase() != 'INPUT')
      return (event.keyCode != 8);
      document.onkeypress = function(e)
      if (e.target.nodeName.toUpperCase() != 'INPUT')
      return (e.keyCode != 8);


      Method 2:

      function checkShortcut()
      if(event.keyCode==8 || event.keyCode==13)
      return false;
      <body onkeydown="return checkShortcut()">

      Anyone know how I can overcome this?
        • 1. Re: Disable Backspace when in input text fields
          Freeky_Bonjela Level 1

          Still haven't found a solution to this. But I have noticed that if i press the tab key and highlight the respective input box I can then use the backspace key to delete. How do I tell the website to focus on the input boxes and not navigation without using the tab key??
          this is a most frustrating problem. please help.
          • 2. Re: Disable Backspace when in input text fields
            SymTsb Level 2
            The TextField class has a tab order property. You may want to look into this. As for disabling the backspace key, you can grab key presses from user input. I'm not 100% on this but you could use Flash to test the key being pressed. If backspace is pressed, find out the current object with focus (unsure of this part), if it's an input box in flash, have flash handle it or if a text box doesn't have focus, send it out to javascript to have it handle it.