A few people have asked for this functionality recently, so I thought I'd write a FAQ.
first of all we need to tell the page to detect when a key is pressed.
[color red]
window.onkeypress = enterSubmit;
function enterSubmit(){
if (event.keyCode==13)
document.forms(0).submit()
}
[/color]
hey thats great!, but hang on - what if you have form validation on the page?
Using submit() will bypass any onsubmit="return ... statements you have in the form, however you could adapt the function to account for this (assuming formValidation() is your function name):
[color red]
window.onkeypress = enterSubmit;
function enterSubmit(){
if (event.keyCode==13){
if (formValidation())
document.forms(0).submit()
}
}
[/color]
Now we're getting near to some decent functionality, but as you can see the form being submitted is the first form on the page.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.