Solved

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

Posted on 2004-10-21
5
198 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 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now