Surendra Sharma

Surendra Sharma

Search This Blog

Monday, June 24, 2013

How to avoid postback on ENTER key press in textbox or How to block ENTER key press in textbox

$(document).ready(function() {

    // Block ENTER key in textbox
    $('#txtSearch').keypress(function(event) {
        if ((event.keyCode || event.which) == 13) {
            event.preventDefault();
            return false;
        }
    });

})

No comments:

Post a Comment