Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > General and Integration Projects > Disable Backspace from master page

Not answered Disable Backspace from master page

Feed from this thread
  • Ray Merckel avatar

    Posted on Apr 5, 2010 (permalink)

    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>

    Reply

  • Rumen Rumen admin's avatar

    Posted on Apr 7, 2010 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > General and Integration Projects > Disable Backspace from master page