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 {

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:)


Post a Comment

Popular posts from this blog

Restore the lost focus of Auto post back controls in asp.net update Panel control

Clone a generic list in C# using extension method

Angular User Session Timeout example step by step

Add Comma automatically while entering amounts in textbox using Javascript

Send bulk Email in asp.net using excel file

Remove Owin from MVC 5 Application and use asp.net custom forms authentication

How to Import CSV File and bind csv file data to gridview in asp.net using c#

Implement Nlog in .Net core MVC application part 1