Forum Moderators: open

Message Too Old, No Replies

submit button question

wanting to run script from 'enter' key, not just submit

         

davidhorn01

4:48 pm on Nov 28, 2003 (gmt 0)

10+ Year Member



Hello all,

I have a log-in / password authentication script which ends with a submit button. THe script works fine when the submit button is pressed, but not when the user types the password and hits enter.

I have tried adding an onEnter command into the code for the input box (rather than the button), but more out of hope than expectation. This didn't work.

Any suggestions?

THanks!

David

dcrombie

5:06 pm on Nov 29, 2003 (gmt 0)



You shouldn't need to do anything special for the newer browsers. If your button is of type="submit" then hitting Enter _should_ have the same effect as clicking it.

RonPK

9:17 pm on Nov 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



David, try something like

<form action=... method=... name=... onSubmit="return yourScript()">

The function yourScript() should return either true or false. If true, the form will be submitted, if false, nothing happens. It doesn't matter whether the user clicks the button or hits enter.