JQuery 屏蔽 jsp 页面 Backspace

$(document).keydown(function (e) {

        var doPrevent;
        
        // for IE && Firefox
        var varkey = (e.keyCode) || (e.which) || (e.charCode);
        
        if (varkey == 8) {

            var d = e.srcElement || e.target; 

            if (d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA') {

                doPrevent = d.readOnly || d.disabled;

                // for button,radio and checkbox
                if (d.type.toUpperCase() == 'SUBMIT'
                    || d.type.toUpperCase() == 'RADIO'
                    || d.type.toUpperCase() == 'CHECKBOX'
                    || d.type.toUpperCase() == 'BUTTON') {

                    doPrevent = true;
                }
            }
            else {

                doPrevent = true;
            }
        }
        else {

            doPrevent = false;
        }

    if (doPrevent)

        e.preventDefault();
    });

你可能感兴趣的:(JQuery 屏蔽 jsp 页面 Backspace)