<form action="" name="searchForm" id="searchForm" method="post">
How can I make it submit using Javascript when user press enter?
edit: assuming I can't edit the <html>
, only using JS (jQuery if really needed)
edit2: it will also be great if myFormProcessF开发者_开发百科unction()
was loaded
accept
Just capture the submit function as if the form had been submitted via the enter button normally.
document.searchForm.submit = function()
{
myFormProcessFunction()
return false; // prevents default action
}
Just capture the submit
function as if the form had been submitted via the enter button normally.
document.searchForm.submit = function()
{
//do something
return false; // prevents default action
}
$('#searchForm').submit(function(e) {
e.preventDefault();
return false;
})
try that, I am sure it'll work. It uses jQuery plulgin, so make sure you have it included.
精彩评论