[thelist] hack to use Enter AS WELL AS Tab on forms
sbeam
sbeam at onsetcorps.net
Thu Feb 3 10:51:51 CST 2005
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;
> }
>
--
# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/
More information about the thelist
mailing list