[thelist] how to disable the return key in web forms?

|| cira || cira at bork.hampshire.edu
Thu Oct 30 15:01:53 CST 2003

You can catch any key pressed inside a page with the event handler 
onKeyPress(). From there, you can figure out which key was pressed and 
what to do if return was pressed. For example,

if (window.event.keyCode == 13) { // if key was the return key
     // if focus of form is at the end, submit form

     // else do nothing

If I'm not mistaken, the JavaScript / keycodes are slightly different for 
Netscape / IE. I don't know how many browsers you want this to work for, 
but I would suggest doing some research online. Here are some links to get 
you started.


Just found that example above, although I'm not sure how good it is.

Hope that helps.


On Thu, 30 Oct 2003, John Dobson wrote:

> Following some usability testing of our web based request form we noticed that some users try to use the return/enter key to move on to the next field.  Unfortunately this action causes the first page of the form to be submitted with the resulting error message saying that certain required fields are not filled in.
> Does anyone know how to change the behaviour of the return/enter key depending on where abouts in the form the focus is?
> Do people think javascript would sort this out?
> Any help would be appreciated
> John Dobson
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !

More information about the thelist mailing list