I have a JavaScript overlay that consists of several input text search criteria. When the user presses the enter key in any of those inputs, I want to mimic the behaviour of the search button.
I know how to handle the enter key if there is only one input. I define the input as:
<input type=\"text\" class=\"txtOrgNmFilter inputBox\" onkeyup=\"ClientsListControl.onFilterKeyup(event);\" />
and in the onFilterKey up
onFilterKeyup: function(event) {
if (event.keyCode == 13) {
$(".txtOrgNmFilter").click();
}
}
My question is as follows: if I have several input texts, do I need to add the onKeyUp attribute in all of them or is there a simpler way (similar to a form submit action)?
My overlay is a table
With this you can bind the same event to all inputs (you can filter more if you want) and when someone clicks ‘enter’ with the focus on some this inputs, it will trigger the ‘click’ event.