[thelist] [javascript] Suppressing enter key form submission

.jeff jeff at members.evolt.org
Tue Feb 18 23:18:03 CST 2003


gabriel,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: gabriel rivera
>
> I'm writing some javascript that submits a form into a
> new window.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

spiffy.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> When the user hits 'enter' instead of clicking submit,
> the onClick never fires and the form posts into the main
> window.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

lemme guess, you're using the onclick event handler on the submit button to
trigger the opening of a new window?

there's a much better way to do what you're trying to do.  in fact,
depending on your requirements for the new window, you can even do it
without any scripting whatsoever.  <doorbell style="insistent" /> *psss*
it's the target attribute, it wants to say "hi".

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Any way to suppress the 'enter' key, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

please don't.  besides, whatcha gonna do for non-js browsers?  make it so
the form doesn't work at all for them (which is probably how you got it
now)?  just let it stay in the same window (if so, why do you care so much
about it being in a new window for js users)?

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] or maybe use an onSubmit instead?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

maybe.  did you try it?  what happened?

here's something to help ya out:

http://members.evolt.org/jeff/code/form_to_window/index.cfm

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list