Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  160] [ 3]  / answers: 1 / hits: 39335  / 15 Years ago, wed, september 2, 2009, 12:00:00

Why is it that a <form> with a single <input> field will reload the form when the user enters a value and presses the Enter, and it does not if there are 2 or more fields in the <form>?.



I wrote a simple page to test this oddity.



If you enter a value in the second form and press Enter, you'll see it reloads the page passing the entered value as if you called GET. why? and how do I avoid it?



<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
<title>testFormEnter</title>
</head>
<body>
<form>
<input type=text name=partid2 id=partid2 />
<input type=text name=partdesc id=partdesc />
</form>
<p>2 field form works fine</p>
<form>
<input type=text name=partid id=partid />
</form>
<p>One field form reloads page when you press the Enter key why</p>
</body>
</html>

More From » html

 Answers
7

This is a little known Quirk that has been out for a while. I know some people have resolved it in various ways.



The easiest bypass in my opinion is to simply have a second input that isn't displayed to the user. Granted not all that user friendly on the backend, it does work to resolve the issue.



I should note that the most common place that I hear of this issue is with IE specifically and not with FireFox or others. Although it does seem to affect them as well.


[#98768] Sunday, August 30, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
taylert

Total Points: 627
Total Questions: 91
Total Answers: 108

Location: Mayotte
Member since Mon, Sep 12, 2022
2 Years ago
taylert questions
;