Disable backspace key using Jquery

Disable backspace key in HTML form using Jquery in simple steps.

While user enters data into application if user accidentally press backspace button then it will redirect to previous page and all entered data would be lost. to eliminate this event we can disable the backspace key using Jquery.

Following is the JQuery script tag you can add to the web page

$(document).keydown(function (e) {
    var nodeName = e.target.nodeName.toLowerCase();

    if (e.which === 8) {
        if ((nodeName === 'input' && e.target.type === 'text') ||
            nodeName === 'textarea') {
            // do nothing
        } else {
            e.preventDefault();
        }
    }
});

The above code can be used seamlessly with any web technology you are using. Hope this will help you in your web application.

Happy coding:)

Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
    Very interesting blog.
    simple-disable-key Crack

    ReplyDelete

Post a Comment

Popular posts from this blog

Implement Logging in CSV file using Nlog in .net core MVC application- part 2

Implement Nlog in .Net core MVC application part 1

Angular User Session Timeout example step by step

Devexpress Datebox date formatting in angular 6 with example