Solved

Form Submission

Posted on 2006-07-13
7
191 Views
Last Modified: 2010-04-09
Hi all

Why a form with single text box gets submitted when pressing enter key,
Below I have given the code, click on the text box and press enter key,
the form gets submitted.. why??

eg:
<html>
<body>
<form name="testing">
<input type="text">
</form>
</body>
<html>

Thanks
Sumesh
0
Comment
Question by:sumachaa
7 Comments
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 17098642
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 17099820
Most browsers will automatically submit a form when the enter key is pressed. Usually they dont if theres no "submit" button but it will all depend on the browser your using.
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 17104168
My fellow experts may be correct, but I'm gonna assume that the problem lies in that it's an <input> tag and get's set as the default.  Try adding default="false" to your input type="text".  I'm probly crazy!

...uhhhh, strike that, I'm definatly crazy, worth a try though.

~Jesse
0
 

Author Comment

by:sumachaa
ID: 17105859
Hi all

I dont want to know the way how to submit the page. I would like to know if there is any specific reason for this, (why the page gets submitted when one text box is there)

This happens in both IE and firefox.

If I add one more text box, this wont happen, ie... pressing enter key will not submit the page

eg
<html>
<body>
<form name="testing">
<input type="text"><br>
<input type="text">
</form>
</body>
<html>
0
 
LVL 17

Accepted Solution

by:
gops1 earned 20 total points
ID: 17107834
When filling out a form, most browsers will cause the form to be submitted if the user's focus is within a single textbox and they hit the Enter key. The specifics of this interaction vary from browser to browser. Some older browsers don't cause a submission upon hitting Enter; others older browser only do it if there is precisely one input form field. Modern browsers, however, all pretty much support the Enter acting as form submission, but even then they still exhibit some slight differences.

The URL below  provided short description on how the Enter key should affect form submission:

http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
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.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

820 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