[thelist] hack to use Enter AS WELL AS Tab on forms

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Thu Feb 3 11:23:43 CST 2005


   Just for the record, it's only XP with Service Pack 2 that doesn't let you reset the keyCode.  This is probably considered a security risk, even though many security precautions seem like nuisances to us.

   The rest of the code I sent should have worked; I apologize for not separating out the keyCode setting since that wouldn't strictly be necessary for it to work (it just would have replaced the rest of the IE code to make the whole thing a lot cleaner).  Looks like you've got it together, so good for you.

Cheers,

Peter

From: sbeam sbeam at onsetcorps.net

OK based a little on the below I've come up with the following that 
seems to work on IE6/W2K and Moz
http://onsetcorps.net/formkeys.php

Peter, it avoids setting keyCode so maybe XP won't barf on it? (also 
thanks for the tip, my Windows is all W2K and I had foolishly assumed 
they were fixing bugs in XPSP2 instead of adding new ones)

To those who lost the OP, this is a hack to allow users to use Enter _as 
well as_ Tab to cycle through form fields - sorry my original subject 
line was a little off. And we still want Enter to submit the form *as 
long as the submit button is focused*

So does this work cross the board? if anyone can check it I appreciate 
it!
thanks,

On Thursday 03 February 2005 08:44 am, Norman Bunn wrote:
> Here is one I picked up a while back off the Dynamic Drive site.
> 
> /***********************************************
> * Disable "Enter" key in Form script- By Nurul 
> Fadilah(nurul at REMOVETHISvolmedia.com)
> * This notice must stay intact for use
> * Visit http://www.dynamicdrive.com/ for full source code
> ***********************************************/
> 
> function handleEnter (field, event) {
> var keyCode = event.keyCode ? event.keyCode : event.which ? 
> event.which : event.charCode;
> if (keyCode == 13) {
> var i;
> for (i = 0; i < field.form.elements.length; i++)
> if (field == field.form.elements[i])
> break;
> i = (i + 1) % field.form.elements.length;
> field.form.elements[i].focus();
> return false;
> }
> else
> return true;
> } 
> 



More information about the thelist mailing list