Solved

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

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…
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…

832 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