[thelist] hack to use Enter instead of Tab on forms

Norman Bunn norman.bunn at craftedsolutions.com
Thu Feb 3 07:44:33 CST 2005

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])
            i = (i + 1) % field.form.elements.length;
            return false;
        return true;

Just add

onkeypress="return handleEnter(this, event)

to each field and you are done.



Norman W. Bunn
norman.bunn at craftedsolutions.com
Crafted Solutions, Inc.
Web Design & Development
Web Site Hosting & Custom Solutions
"Get the results the Internet promises;
 get the 'Net Result' from Crafted Solutions!"

More information about the thelist mailing list