[Javascript] onEnter Submit js

rahul soni rahulsoni_in at rediffmail.com
Wed Nov 13 12:23:23 CST 2002


 
<script language="JavaScript">
NS4 = (document.layers) ? true : false;

function checkEnter(event)
{     
    var code = 0;
    
    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
    if (code==13)
        document.myform.submit();
}
</script>

   <input type="text" name="User" size="15" onKeyPress="checkEnter(event)">


-------
In response to

[Javascript] Press enter submits form
Harry Love javascript at LaTech.edu
Mon, 26 Aug 2002 13:44:48 -0700

Previous message: [Javascript] Press enter submits form
Next message: [Javascript] IE popup object
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

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

<snip>
Hi all- how do I use javascript to submit the form (or press a
particular button) when the enter key is pressed?
</snip>

David,
I think (and someone please correct me) that the [enter] key is already
the default keystroke for submitting a form, so no need for a script
there.

<snip>
This form can have multiple buttons.
</snip>

I'm confused by this statement.  Are you saying you have multiple submit
buttons, or multiple buttons that should be associated with the [enter]
key, or something else?  Please explain.

Harry




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






More information about the Javascript mailing list