Disable Backspace from master page

Thread is closed for posting
3 posts, 0 answers
  1. 5B5C1A00-ACE8-4E7E-ABCE-4ED5BEBC976B
    5B5C1A00-ACE8-4E7E-ABCE-4ED5BEBC976B avatar
    5 posts
    Member since:
    Mar 2009

    Posted 05 Apr 2010 Link to this post

    Requirements

    RadControls version 2009.3.1314.35

     all

    .NET version 3.5

     all

    Visual Studio version

     all

    programming language

     JavaScript

    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    JavaScript to disable backspace from master page except in textbox, datetime, or textarea...

    <script type="text/javascript">
        function killBackSpace(e) {
            e = e ? e : window.event;
            var t = e.target ? e.target : e.srcElement ? e.srcElement : null;
            if (t && t.tagName && (t.type && /(password)|(text)|(file)/.test(t.type.toLowerCase())) || t.tagName.toLowerCase() == 'textarea')
                return true;
            var k = e.keyCode ? e.keyCode : e.which ? e.which : null;
            if (k == 8) {
                if (e.preventDefault)
                    e.preventDefault();
                return false;
            };
            return true;
        };
     
        if (typeof document.addEventListener != 'undefined')
            document.addEventListener('keydown', killBackSpace, false);
        else if (typeof document.attachEvent != 'undefined')
            document.attachEvent('onkeydown', killBackSpace);
        else {
            if (document.onkeydown != null) {
                var oldOnkeydown = document.onkeydown;
                document.onkeydown = function(e) {
                oldOnkeydown(e);
                killBackSpace(e);
                };
            }
     
            else
                document.onkeydown = killBackSpace;
        }
    </script>

  2. DF60784D-55A5-4263-9F10-A12FA48C9ADC
    DF60784D-55A5-4263-9F10-A12FA48C9ADC avatar
    14477 posts
    Member since:
    Apr 2022

    Posted 07 Apr 2010 Link to this post

    Hi Ray,

    Thank you for sharing this code snippet with the community.

    Despite that is not directly related to RadControls for ASP.NET AJAX controls, I decided to post it since it could be helpful in scenarios when using the Telerik controls.

    I also updated your Telerik points for your contribution.

    Greetings,
    Rumen
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. D1D3C2E7-7AFD-436F-BB7B-68AA921ADFA5
    D1D3C2E7-7AFD-436F-BB7B-68AA921ADFA5 avatar
    84 posts
    Member since:
    Aug 2007

    Posted 03 Feb 2014 in reply to 5B5C1A00-ACE8-4E7E-ABCE-4ED5BEBC976B Link to this post

    Was looking for this for awhile. Works great! Thanks!
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.