Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-10-21
5
Medium Priority
?
206 Views
Last Modified: 2008-01-09
HI There,
I would like to know how I can disable the enter key when it's pressed on a web form?

Sean
0
Comment
Question by:bullrout
  • 2
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 12367510
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
 
LVL 33

Accepted Solution

by:
sajuks earned 2000 total points
ID: 12367585
//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
 
LVL 5

Author Comment

by:bullrout
ID: 12367772
Hi All,

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

Sean
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12367917
Thanks for the point and grade
0
 
LVL 5

Author Comment

by:bullrout
ID: 12367936
no problem, the code works really well and I needed it now!

I appreciate the help :)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question