Monday, June 10, 2013

IE 9/10 Enter Key causing Form Submit / Button Click workaround

If you ever run into a problem where if you press enter inside a page and the page suddenly submits or a button click event launches, you need to manually stop the enter event from propagating outside a particular div.

//"Enter" Key is taken as a submit action by default on IE 9/10
//Prevent Enter key event from propagating outside the grid.
$('#SUBUL_01_DIV_GRID').keypress(function(e) {
    if(e.which == 13) { 
        e.preventDefault(); 
    }
});
IE, causing massive amount of frustration to web developers like always..

No comments:

Post a Comment