stop [ENTER] from sending the form in NN/Firefox

  • Thread starter Perttu Pulkkinen
  • Start date
P

Perttu Pulkkinen

I use hit two function to stop [ENTER] from sending the form. First one I
use to move focus to the next desired field, second one to do nothing (when
there is no desired field to go).

Works in IE & Opera. How can I make these Netscape/Firefox-compatible (while
still keep them working in IE/Opera)?

function moveto(goal)
{
if(window.event && window.event.keyCode == 13)
document.getElementById(goal).focus();
return !(window.event && window.event.keyCode == 13);
}

function noenter()
{
return !(window.event && window.event.keyCode == 13);
}
 
D

Daniel Kirsch

Perttu said:
I use hit two function to stop [ENTER] from sending the form. First one I
use to move focus to the next desired field, second one to do nothing (when
there is no desired field to go).

Works in IE & Opera. How can I make these Netscape/Firefox-compatible (while
still keep them working in IE/Opera)?

function moveto(goal)
{
if(window.event && window.event.keyCode == 13)
document.getElementById(goal).focus();
return !(window.event && window.event.keyCode == 13);
}

function noenter()
{
return !(window.event && window.event.keyCode == 13);
}

You need to pass the event object to your functions. window.event is a
MS implementation. The event object will be passed as first argument to
your event listener.

Daniel
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top