Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Intermediate
Jun 30, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Submitting a Form with the Enter Key

Using the IE browser application, you can press the <Enter> key while filling a form to submit the form. Indeed, this is a desirable feature for any Windows application. In order to make this work for all browser applications, you just need to add a few lines of code.

The method explained here traps the keyboard events to implement this. This works on all browsers —it was tested on Internet Explorer, Netscape Navigator, Mozilla and Opera.

<script language="JavaScript">
function processEnterKey(evnt) {
    if (evnt.which == 13)

if (navigator.appName != "Microsoft Internet Explorer")
onkeydown = processEnterKey;
'myForm' identifies the form to be submitted. If the document has several forms, you may need additional logic to determine which form to submit.

Ajith Prasad
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date