Solved

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

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to implement server side field validation and display customized error messages to the client.
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

626 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