[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

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
0
bullrout
Asked:
bullrout
  • 2
  • 2
1 Solution
 
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
 
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
 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now