Solved

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

Posted on 2004-10-21
5
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

752 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