PDA

View Full Version : onkeydown function


jolietjake
10-07-2002, 08:40 AM
Hi! Here's a question.

I have a form without any submit button and I want to run a function that submits my form when the user push the enter button. How can I do it?

Thanks

---------------------------------------------

Joliet Jake, Master of Blues & Rythm

tommysphone
10-07-2002, 01:59 PM
actually I'd reconsider. Some surfers press enter to go from one field to the next, rather than tab. If you have validation on your form this is fine as it won't go till completed properly. I'd go for the submit button which will save time and hassle. If you definately do not want a submit button then I cannot help.

Sorry.

sekhar_maturi
10-07-2002, 02:08 PM
In the form add the attribute onKeyPress="submitForm()"

and define the following function in head

function submitForm()
{
if(window.event.keyCode==13)
{
document.formName.submit();
}
}