Disable Enter key in Forms

K

kevinold

Hello everyone,

I've searched google and found several scripts that will "Disable" the
enter key in forms, but none of them seem to work in Firefox 1.0.

One such is here http://www.phpfreaks.com/quickcode/code/162.php

Also, on another note, where did the Netscape Javascript reference site
(also known as DevEdge) go? Anyone aware of where other Javascript
references are?

Any help is appreciated!

Kevin
 
G

goulart

You should try capturing the onkeypress event at the document level,
where it can be blocked.

KeyPressEvent = function (event) {
if (event.which != 13) return true;

event.returnValue = false;
event.preventDefault();
}
document.addEventListener("keypress", KeyPressEvent, true);


that should work. track the event.target to get only the Enter on a
textarea etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top