javascript - jQuery and ASP.NET - forcing button click -


I have an ASP.Net page that has a form on it. I also have a search form for it. The search is in the upper-right portion of the page, so the button for search has already been added to Control Hitachi.

When you are working on other forms and pressing it, it will click on the Search button I do not like it, I would like that the form button is clicked when you press Enter.

I tried to use jQuery like this:

  $ ('#textboxId') keyboard (function (e) {if (e.keycode === 13) {$ ('# buttonId'). Click (); e.preventDefault ();}});  

but submitted form, which means that the client-side verification was not run (i.e., the onclick event handler was not running on the button).

What is the best way to get it?

Try it instead.

  $ ('# textboxID') keydown (function (e) {if (e.keyCode === 13) {E.P.exe Default (); $ ('# button ID '). Trigger (' click ');}});  

Comments