[thelist] RE: Cancelling onKeyDown in Netscape 6

Matt Feldman mfeldman at wwwood.net
Mon Nov 19 13:19:36 CST 2001


In response to Jeffs comment about my cancelling onKeyDown question:  

The onKeyDown cancelling is only one possible solution to the problem.
The problem I'm having is that we have several pages that have multiple
options for the user to select (Save, cancel, save & add new, save &
return to list, etc.) and if they just submit using the enter key, the
app doesn't know what the user wants to be done.  This could be solved
by a default, or perhaps prompting the user, but those may not be
options. I was trying to assess whether cancelling the form submit is a
viable option code-wise before I discuss solutions with my manager.  So
does anyone have suggestions for the original question?  

>I'm trying to stop a form from submitting when the user presses enter
on a text field.  In IE 5 and Netscape 4, I >have a working solution: in
the onKeyDown attribute I call this function:
>
>	function cancelEnter(evt) {
>		if (evt.keyCode == 13) {
>			return false;
>		}
>	}
>
>I have to replace the evt.keyCode with evt.which in Netscape 4, but
that's not a problem.  In Netscape 6, however, >it catches the event
fine, but returning false does not cancel the form submit.  I know this
has something to do 
>with event bubbling, but I don't know enough about it to solve the
problem.

thanks,

Matt




More information about the thelist mailing list