Want HTML form submit to do nothing

Viewed 112727

I want an HTML form to do nothing after it has been submitted.

action=""

is no good because it causes the page to reload.

Basically, I want an Ajax function to be called whenever a button is pressed or someone hits Enter after typing the data. Yes, I could drop the form tag and add just call the function from the button's onclick event, but I also want the "hitting enter" functionality without getting all hackish.

10 Answers
<form id="my_form" onsubmit="return false;">

is enough ...

Just replace 'action=""' withonsubmit='return false'. That's it.

Related