[thelist] Stopping Form Submission when Enter is hit

Darren Darren at web-bitch.co.uk
Wed Jul 18 08:58:58 CDT 2001


On 18 July 2001 at 14:54:31, Shashank Tripathi <sub at shanx.com> wrote:

ST> In the form's "onSubmit()" function, call a function called, say,
ST> "checkEntries()". In this function, if required info is not entered, then
ST> "return false". This prevents the form from being submitted.

i thought of this, and the form does validate the entries and if
they're not all there the submit is halted.  i can trap the enter key
being hit anywhere on the form (onkeypress in the form tag), but that
either screws up other validation on the form, or the onclick event is
fired anyway...very annoying.

but the problem is that the first submit button on the page is a
'delete entries' button, and it's this that's being fired...what i
would like is some way to have the deleteEntries() function run *only*
when the required button is hit, not when the user hits return.

i could just make the delete buttons into normal buttons and put the
values we need to pass through in the querystring, but this seems
slightly insecure...and i was hoping for something a bit more elegant!
;>

hope that's a bit clearer. :>

darren.





More information about the thelist mailing list