disabling the "enter" key when its pressed on a form?

HI There,
I would like to know how I can disable the enter key when it's pressed on a web form?

Sean
LVL 5
bullroutAsked:
Who is Participating?
 
sajuksCommented:
//ie plus ns soln
<html>



<body>
<form onKeyPress="if(document.all){var k=event.keyCode;}else{var k=event.which;}if(k==13){return false;}">
Enter name<input type=text > 
<input type = "submit">
</form>
</body>
</html>
0
 
RoonaanCommented:
try the one below. Will transfer a return into a tab hopefully. Haven't tested it though

<form onkeypress="if(window.event.keyCode==13) window.event.keyCode = 9;">

or

<form onkeypress="if(window.event.keyCode==13) return false;">

Regards

-r-
0
 
bullroutAuthor Commented:
Hi All,

Thanks for the answers, I think I will take sajuks suggestion it works well.

Sean
0
 
sajuksCommented:
Thanks for the point and grade
0
 
bullroutAuthor Commented:
no problem, the code works really well and I needed it now!

I appreciate the help :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.