Question

I have a webpage where i have a table of parts and column filtering inputs above each column so people can filter the parts in the table, the jQuery works on keyup so every time they type a letter it filters the table dynamically. However the people in my office, out of habit, keep hitting Enter after typing a filter text in the box, this in turn submits the form for processing. What can i do? Disable the Enter key or something similar?

Was it helpful?

Solution

Yes, but only block the enter on the fields that should not submit the form. Also this will need to be bound on keypress, rather than keyup.

$('#target').bind('keypress', function(e) {
  if (e.which == '13') {
     return false;
   }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top