How to remove Default Enter Click from page.
that is Have one save button in my page that is Submit button. When I click Enter its allways hitting save button. even If i am doing something else.
Can any body tell me how to remove this Default Enter click from my page.
Ex:
I have Grid with Filterable Columns
When I am doing Filter on the Gr开发者_如何学JAVAid its setting focus to Save button that is when I select anyting to filter from the Grid its allways setting focus to Save button.
Thanks
Using e.preventDefault();
you can stop the default behavior
$(window).keydown(function(e) {
if (e.keyCode == 13) // if it is enter
e.preventDefault(); // stop default behavior
});
Most simple way is replacing the submit button with ordinary button that submit the form with JS code when clicked:
<input type="button" onclick="this.form.submit();" value="Submit" />
Downside is user won't be able to submit without JS enabled, so you can add the ordinary submit button within <noscript>
tags.
精彩评论