Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

disabling the "enter" key in FORMs

Posted on 1998-05-27
8
Medium Priority
?
137 Views
Last Modified: 2010-04-09
IE 4 automatically submits our FORMs when visitors hit the key -- even if the form is not filled out. We really don't want to make all the fields required fields with Java Script to counteract this peculiarity. We just want to disable the enter key from effecting the form submission. Is there an HTML attribute that will prevent the enter key from this action?

This problem does not seem to impact Netscape.
0
Comment
Question by:bheerman
[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
  • 2
  • +2
8 Comments
 

Expert Comment

by:jamesbrown
ID: 1843963
No.  There is no way in HTML to enable/disable form buttons without using JavaScript or VBScript.  I am surprised that there is no impact on Netscape - an empty field is an empty field.
0
 

Author Comment

by:bheerman
ID: 1843964
Okay. Just let me clarify to make sure I understand. The user hits the enter key halfway through the form inadvertantly. They are not on the form button, they are in another field, like a radio button or a drop down. This submits the form in IE 4 (but not in Netscape). There is nothing that can be done short of requiring these fields with Java Script? I don't understand why the enter key would submit the form if the user is not in the form submit button field.
0
 
LVL 28

Expert Comment

by:sybe
ID: 1843965
You could add an onChange to each form-element, check what the last keypress was, and make nothing happen when it was return, and in every other case add the key typed to the form element.

I cannot check with MSIE4 right now, but i guess submission only happens when the visitor is filling out a textfield or textarea, is that right ?



0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:jamesbrown
ID: 1843966
Now I understand a little more, thanks for clarifying.  Yes, IE will submit the form when the user hits <ENTER> but only when the user is in a TYPE="text" field (or on the submit button).  As the other comments state, there is no way within HTML (via a tag) to disable this feature in IE4 other than with JavaScript.

BTW, Netscape (I believe) will do this as well _but_ only if the only field in the form is a text field.

JB
0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1843967
this is JavaScript, but may be worth a try:
a) declare a variable in the <HEAD> part of your page:
  var submitnow = false

b) add onSubmit="return submitnow" to the <FORM> tag

c) now add a onClick="submitnow=true" to your <INPUT TYPE="SUBMIT">

I have not tested this; it may be that you have to add this to your submit button tag:
onClick="submitnow=true; this.form.submit()" (I assume it's no mailto: form)

Tell me if you like it / if it works.
0
 

Author Comment

by:bheerman
ID: 1843968
Ok. Thanks all.

jamesbrown should get 50.
sybe, 10.
christian wenz, 10
0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1843969
the easiest way to achieve this: let jamesbrown answer this question, he will get 50 points after you rate him. Then, ask questions labeled "just for sybe" and "just for xx" and state there that these questions shall only be answered by the specific persons. Rate each of this questions 10 points.
0
 
LVL 8

Accepted Solution

by:
jhurst earned 150 total points
ID: 1843970
Make the form a sort of pseudo form.  What I mean by this is: leave the form alone except that you get rid of the action and replace it with an onSubmit=whatEver().  Now, when he submits this form you will get control in your whatEver() function.  You also place in the form a <input type=button value='submit' onClick=heDidIt()> tag.  

So now, the ENTER key will get you to the whatEver and the button will get you to heDidIt.  In heDidIt you copy all variables from the pseodo form to another, hidden form with the same fields, except that they are hidden, and then do a document.reallyDoIt.submit() where this is the second and real form.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

618 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