473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Enter key will not submit the form

I have a form I want to submit to itself. I want to be able to type in a
list of numbers and submit the form and have that list show up on the same
form under the text box I typed them into and the buttons. The problem is
when I post a form to itself, the Enter key will not submit the form, it
only clears the contents of the text box. The only way I can submit is to
click the submit button. Here is a simplified version of my code that I had
to comment out so you could see the source. Note the name of the page is
Page1.asp

'<%@ Language=VBScript %>
'<HTML>
'<HEAD>
'</HEAD>
'<BODY>
'<p>Enter numbers separated by a comma.</p>
'<form action="Page1.asp" method="POST" id=form1 name=form1>
'<p><input type="text" name="ListID" size="50" maxlength="1000"></p>
'<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" 'name="B2"></p>
'</form>
'<%if Request.Form("B1")="Submit" then
' lvListID=Request.Form("ListID")
' Response.Write lvListID
'End IF '%>
'</BODY>
'</HTML>

I know I've posted a page to itself before and had never had problems with
the Enter key not submitting. What am I doing wrong?
Thanks
Mike
Jul 22 '05 #1
15 6526
It most likely is submitting just fine. You're just not using the correct
criteria to determine if it was submitted. Try either evaluating your IF
statement based on the contents of Request.Form("ListID") or
Request.ServerVariables("REQUEST_METHOD"). To verify that your form is
submitting, try using this code and pressing enter:

<HTML>
<HEAD>
</HEAD>
<BODY>
<p>Enter numbers separated by a comma.</p>
<form action="page1.asp" method="POST" id=form1 name=form1>
<p><input type="text" name="ListID" size="50" maxlength="1000"></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></p>
</form>
<%

For Each thing in Request.Form
Response.Write thing & " = " & Request.Form(thing) & "<hr />"
Next

%>
</BODY>
</HTML>

Ray at work

"M Smith" <ms****@avma.org> wrote in message
news:e9**************@TK2MSFTNGP12.phx.gbl...
I have a form I want to submit to itself. I want to be able to type in a
list of numbers and submit the form and have that list show up on the same
form under the text box I typed them into and the buttons. The problem is
when I post a form to itself, the Enter key will not submit the form, it
only clears the contents of the text box. The only way I can submit is to
click the submit button. Here is a simplified version of my code that I had to comment out so you could see the source. Note the name of the page is
Page1.asp

'<%@ Language=VBScript %>
'<HTML>
'<HEAD>
'</HEAD>
'<BODY>
'<p>Enter numbers separated by a comma.</p>
'<form action="Page1.asp" method="POST" id=form1 name=form1>
'<p><input type="text" name="ListID" size="50" maxlength="1000"></p>
'<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" 'name="B2"></p>
'</form>
'<%if Request.Form("B1")="Submit" then
' lvListID=Request.Form("ListID")
' Response.Write lvListID
'End IF '%>
'</BODY>
'</HTML>

I know I've posted a page to itself before and had never had problems with
the Enter key not submitting. What am I doing wrong?
Thanks
Mike

Jul 22 '05 #2
It's a bug in IE (imagine that). When there is only one text box, IE messes
it up.

I don't remember the work-around (funny that IE is now the browser to work
around), but I think if you add a hidden field, or a text box with the
visibilty hidden it will work.

Bob Lehmann

"M Smith" <ms****@avma.org> wrote in message
news:e9**************@TK2MSFTNGP12.phx.gbl...
I have a form I want to submit to itself. I want to be able to type in a
list of numbers and submit the form and have that list show up on the same
form under the text box I typed them into and the buttons. The problem is
when I post a form to itself, the Enter key will not submit the form, it
only clears the contents of the text box. The only way I can submit is to
click the submit button. Here is a simplified version of my code that I had to comment out so you could see the source. Note the name of the page is
Page1.asp

'<%@ Language=VBScript %>
'<HTML>
'<HEAD>
'</HEAD>
'<BODY>
'<p>Enter numbers separated by a comma.</p>
'<form action="Page1.asp" method="POST" id=form1 name=form1>
'<p><input type="text" name="ListID" size="50" maxlength="1000"></p>
'<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" 'name="B2"></p>
'</form>
'<%if Request.Form("B1")="Submit" then
' lvListID=Request.Form("ListID")
' Response.Write lvListID
'End IF '%>
'</BODY>
'</HTML>

I know I've posted a page to itself before and had never had problems with
the Enter key not submitting. What am I doing wrong?
Thanks
Mike

Jul 22 '05 #3
Worked fine for me using IE.

Ray at work

"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
It's a bug in IE (imagine that). When there is only one text box, IE messes it up.

I don't remember the work-around (funny that IE is now the browser to work
around), but I think if you add a hidden field, or a text box with the
visibilty hidden it will work.

Bob Lehmann

Jul 22 '05 #4
M Smith wrote:
...The problem is when I post a form to itself, the Enter key
will not submit the form, it only clears the contents of the
text box...

<input type="text" name="ListID" size="50" maxlength="1000">
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" 'name="B2">


It sounds as if the focus is on the RESET input. Does the behavior change if
you convert the RESET to a button?

<input type="button" value="Reset" onclick="this.form.reset()">

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #5
Dave, try it with the code he posted, and you'll see what I'm talking about.

Ray at work

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
It sounds as if the focus is on the RESET input. Does the behavior change if you convert the RESET to a button?

<input type="button" value="Reset" onclick="this.form.reset()">

Jul 22 '05 #6
Ray Costanzo [MVP] wrote:
Dave, try it with the code he posted, and you'll see what I'm talking
about.


Yeah, you're probably right, Ray.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #7
Maybe the problem is actually that his sound his muted and he's not
hearing the Start Navigation sound. ;]

Ray at work

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
Ray Costanzo [MVP] wrote:
Dave, try it with the code he posted, and you'll see what I'm talking about.
Yeah, you're probably right, Ray.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per

message. Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your question is worth asking, it's worth posting.

Jul 22 '05 #8
You're right. I was close though.

The bug I was thinking about involved the submit button. When there is a
single textbox, and the "Enter" key is used to submit the form, the onclick
event of the submit button doesn't fire, nor is information about the button
sent to the server.

This discusses the problem in an ASP.Net context, but the same applies to
ASP pages.....
http://www.bbits.co.uk/blog/archive/2004/03/09/191.aspx

Bob Lehmann

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:eS**************@tk2msftngp13.phx.gbl...
Worked fine for me using IE.

Ray at work

"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
It's a bug in IE (imagine that). When there is only one text box, IE

messes
it up.

I don't remember the work-around (funny that IE is now the browser to work around), but I think if you add a hidden field, or a text box with the
visibilty hidden it will work.

Bob Lehmann


Jul 22 '05 #9

"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
You're right. I was close though.

The bug I was thinking about involved the submit button. When there is a single textbox, and the "Enter" key is used to submit the form, the onclick event of the submit button doesn't fire, nor is information about the button sent to the server.
Is that really a bug? I personally would only want an onclick event
to fire on click.

This discusses the problem in an ASP.Net context, but the same applies to ASP pages.....
http://www.bbits.co.uk/blog/archive/2004/03/09/191.aspx


In my opinion, it's a bug in ASP.NET and it's attempt to make a
client-server environment behave like it's not that.

Ray at work

Jul 22 '05 #10
>> Is that really a bug?
I'd be less inclined to think so if it wasn't for the fact that adding a
second textbox causes the onclick to fire on the client, and button
information (value) to be sent to the server when hitting "Enter".
In my opinion, it's a bug in ASP.NET
The same behavior in .asp and .htm pages.

Bob Lehmann

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:uW**************@TK2MSFTNGP09.phx.gbl...
"Bob Lehmann" <no****@dontbotherme.zzz> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
You're right. I was close though.

The bug I was thinking about involved the submit button. When there

is a
single textbox, and the "Enter" key is used to submit the form, the

onclick
event of the submit button doesn't fire, nor is information about

the button
sent to the server.


Is that really a bug? I personally would only want an onclick event
to fire on click.

This discusses the problem in an ASP.Net context, but the same

applies to
ASP pages.....
http://www.bbits.co.uk/blog/archive/2004/03/09/191.aspx


In my opinion, it's a bug in ASP.NET and it's attempt to make a
client-server environment behave like it's not that.

Ray at work

Jul 22 '05 #11
"M Smith" wrote in message news:e9**************@TK2MSFTNGP12.phx.gbl...
:I have a form I want to submit to itself. I want to be able to type in a
: list of numbers and submit the form and have that list show up on the same
: form under the text box I typed them into and the buttons. The problem is
: when I post a form to itself, the Enter key will not submit the form, it
: only clears the contents of the text box. The only way I can submit is to
: click the submit button. Here is a simplified version of my code that I
had
: to comment out so you could see the source. Note the name of the page is
: Page1.asp
:
: '<%@ Language=VBScript %>
: '<HTML>
: '<HEAD>
: '</HEAD>
: '<BODY>
: '<p>Enter numbers separated by a comma.</p>
: '<form action="Page1.asp" method="POST" id=form1 name=form1>
: '<p><input type="text" name="ListID" size="50" maxlength="1000"></p>
: '<p><input type="submit" value="Submit" name="B1"><input type="reset"
: value="Reset" 'name="B2"></p>
: '</form>
: '<%if Request.Form("B1")="Submit" then
: ' lvListID=Request.Form("ListID")
: ' Response.Write lvListID
: 'End IF '%>
: '</BODY>
: '</HTML>
:
: I know I've posted a page to itself before and had never had problems with
: the Enter key not submitting. What am I doing wrong?
: Thanks
: Mike

The problem is the Submit button doesn't post a value when you press ENTER
from the text box. You're testing the value of the button and there isn't
one. If you tab to the button and press ENTER, SPACE or you click on the
submit button, then it posts the value of the button. It sounds like a bug
to me or (cough) a "by design" change.

I wouldn't test if a button had been pressed when submitting to a page if
I'm looking for a value from a text box. I would just check to see if the
value exists since it's posting to itself and it doesn't have a default
value, clearly it is there only if it had been posted. Yes, it could have
been posted from somewhere else but that is easy enough to test for also.

Adding a hidden field as Bob suggested doesn't make it work either. I
didn't check another text field with visibility: hidden or display: none.

You can restrict the ENTER key from being used to submit the form with:
<form action="Page1.asp" method="POST" id="form1" name="form1"
onsubmit="return false">

Then you can add onclick events to your buttons:
<p><input id="b1" type="button" value="Submit"
onclick="document.form1.submit()" />
<input id="b2" type="button" value="Reset"
onclick="document.form1.reset()" />
</p>

However, you're not going to get a value for the submit button. It appears
your approach is what needs to be modified because B1 will always =
"Submit", whether it gets submitted or not. What you need to test for is a
value in ListID and if found, display it. But, you can even eliminate that
test and just display it anyway since you have no presentable text with it.
If it's empty, it will not display and if it has content, it will.

Or, you can add a hidden field and set the value of the button, but I would
only do this if I had multiple buttons and I wanted to know which one was
pressed. If you only have the two, as you do currently, only the submit
button can submit the form. That's not the best way to validate a form
being posted upon entry.

I remember my first problem with forms was MAPI mail submissions including
the submit button. The way around it was to remove the name= from the
submit button so it did not include it. Perhaps MSFT over simplified it
now?! (O:=

Hidden field and ENTER key restricted from posting from the text field:
http://kiddanger.com/lab/msmith/page1.asp
Source:
http://kiddanger.com/lab/msmith/ss_page1.asp

Only change is displaying the value if it exists:
http://kiddanger.com/lab/msmith/page2.asp
Source:
http://kiddanger.com/lab/msmith/ss_page2.asp

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #12
Roland Hall wrote:
The problem is the Submit button doesn't post a value when you press
ENTER from the text box.


Unless (a) there are multiple TEXT inputs, or (b) the browser is not IE. It
is only the single text input case with Internet Explorer that exhibits this
behavior.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #13
"Dave Anderson" wrote in message
news:e8**************@TK2MSFTNGP15.phx.gbl...
: Roland Hall wrote:
: > The problem is the Submit button doesn't post a value when you press
: > ENTER from the text box.
:
: Unless (a) there are multiple TEXT inputs, or (b) the browser is not IE.
It
: is only the single text input case with Internet Explorer that exhibits
this
: behavior.

Yes, I agree it is an IE issue. Did it sound like I was saying something
different re: it being a bug?
Jul 22 '05 #14
Roland Hall wrote:
Unless (a) there are multiple TEXT inputs, or (b) the browser is not
IE. It is only the single text input case with Internet Explorer
that exhibits this behavior.


Yes, I agree it is an IE issue. Did it sound like I was saying
something different re: it being a bug?


You certainly did not suggest it was an Internet Explorer bug. I personally
do not consider it a bug, since this is open to interpretation:

17.13.2 Successful controls
A successful control is "valid" for submission. Every successful
control has its control name paired with its current value as part
of the submitted form data set. A successful control must be
defined within a FORM element and must have a control name.

http://www.w3.org/TR/html401/interac...s.html#h-17.13

The above does not require that a submit button be considered successful --
it merely sets a threshold for such consideration. MS obviously does not
consider the button activated when [Enter] in pressed in the text input.

Who can say why? Perhaps this goes back to the transition from ISINDEX to
text inputs. Good question for the blogs, though.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #15
It's weird, though, that it is considered activiated when there is more than
one textbox in the form.

Bob Lehmann

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Roland Hall wrote:
Unless (a) there are multiple TEXT inputs, or (b) the browser is not
IE. It is only the single text input case with Internet Explorer
that exhibits this behavior.
Yes, I agree it is an IE issue. Did it sound like I was saying
something different re: it being a bug?


You certainly did not suggest it was an Internet Explorer bug. I

personally do not consider it a bug, since this is open to interpretation:

17.13.2 Successful controls
A successful control is "valid" for submission. Every successful
control has its control name paired with its current value as part
of the submitted form data set. A successful control must be
defined within a FORM element and must have a control name.

http://www.w3.org/TR/html401/interac...s.html#h-17.13

The above does not require that a submit button be considered successful -- it merely sets a threshold for such consideration. MS obviously does not
consider the button activated when [Enter] in pressed in the text input.

Who can say why? Perhaps this goes back to the transition from ISINDEX to
text inputs. Good question for the blogs, though.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 22 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: T.E. | last post by:
Hi all, I'm a newbie in php. I encounter a problem with php form that has only one textfield. If I click on the submit button, the form works fine. However, when I press 'enter', the form...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
4
by: Peloux | last post by:
Hi, I have written some htc in order to validate data in a form. most of htc are attached on 'onblur' event. Now, we would like to use the Enter Key to sublit form, so we use the following...
5
by: Eric | last post by:
Hi All, I'm very experienced in traditional ASP and am new to (am learning) ASP.NET. FYI: I am initially learning ASP.NET with VB.NET to ease the transition for me. I have encountered what I...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
6
by: Andrew Willett | last post by:
I have a web form that is a child of a Master Page. It is a login form for forms authentication. When you fill in the username and password box and press ENTER it doesnt process any of the...
10
by: Perry van Kuppeveld | last post by:
Hi, I have a problem with formatting a table including text fields wich can contain up to 255 chars. I need a table with 3 columns: - First column 50 % over the with a rowspan of the total...
12
by: Daniel Klein | last post by:
I'm pretty new at php and web stuff so please be gentle with me. I'm trying to get a form to submit when the user presses the Enter key. I do not want to use javascript. I've googled this to...
6
by: Mark B | last post by:
I have a function that looks up a SQL table to see if a search term matches. It works fine but so far there are two things yet to work: 1) After entering a search term and pressing Enter, nothing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.