I have an ASP.NET page that has a form on it. It also has a search form. The search is located in the upper right corner of the page, so the search button is the first hierarchy of the control added.
When you are working on another form and press the enter key, it will click on the search button. I do not want this, I would prefer that when you click the button, click the button to click the form.
I tried using jQuery as follows:
$('#textBoxId').keyup(function(e) { if(e.keyCode === 13) { $('#buttonId').click(); e.preventDefault(); } });
But the form presented means that the client-side check was not performed (i.e. the onclick event handler did not start on the button).
What is the best way to achieve this?
source share