473,574 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit form

CJM
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 should be submitted as if the button is pressed. Is
this correct?

Does this behaviour vary across browsers?

Chris

--
cj*******@REMOV EMEyahoo.co.uk
[remove the obvious bits]
Jul 22 '05 #1
6 3093
"CJM" wrote in message news:eK******** ******@TK2MSFTN GP15.phx.gbl...
: 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 should be submitted as if the button is pressed. Is
: this correct?
:
: Does this behaviour vary across browsers?

I have no idea. This is how I test for it.

dim postback
postback = Request.ServerV ariables("REQUE ST_METHOD")
if postback = "POST" then
' process my form
end if

If you're looking for it to post on the URL then the method will be GET.

--
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 #2
CJM
I've just realised part/all of the problem... My application uses a
client-side script to validate the form inputs, before setting the Action
property of the form and submitting it. Therefore, if the button is not
pressed, the validation code is not run and the Action property is not - so
the page POSTs back to itself.

Therefore I need to be able to detect that the Enter key has been pressed,
in which case I can validate the code and submit the form accordingly. Can
anyone give me any pointers on the best way to do this?

[Follow-ups set to m.p.s.jscript]

Thanks

Chris

>>>>Origina l Post >>>>>>>>>>>>


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 should be submitted as if the button is pressed. Is
this correct?

Does this behaviour vary across browsers?

Jul 22 '05 #3
Gazing into my crystal ball I observed "CJM" <cj*******@news group.nospam>
writing in news:eK******** ******@TK2MSFTN GP15.phx.gbl:
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 should be submitted as if the button is
pressed. Is this correct?

Does this behaviour vary across browsers?

Chris


This _should_ work across browsers, but it always best to check server
side.

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
Jul 22 '05 #4
Hi Chris,

As for the validating form inputs and submit it question you mentioned,
here are some of my understanding and suggestions:

1. For HTML page in webbrowser, when there is some entry fields and submit
buttons, if we set focus on a certain entry field( for example input some
value in a textbox) and hit enter key, we will found the page be submited
as if one fo the submit button is clicked. At lease IE browser will behave
as this. In fact, this is because when the entry field is accepting input,
the focus of the page is on the first submit button on the form, you can
have a check on this, so when we hit enter key, the focused submit button
is clicked. Also, this is not always true when the page's structure become
very complex. And I know many guys will manually use some script to hook
the entry fields's key down event and use script to submit the form in that
event.

2. For validation the form's fields and submit it to the correct page, my
suggestion is we just submit the form to the same page self. Then in the
page's code block, we do the validation, when the input data are valid, we
use server.transfer to redirect the request to our target processing page(
the forms collection will reserve when using server.Transfer to skip from
different page). For example:

<%
dim method

method = Request.ServerV ariables("REQUE ST_METHOD")
if method = "POST" Then

' do the validation here
if Request.Form("u sername") = Request.Form("p assword") Then

Server.Transfer ("result.asp ")
else
Response.Write( "Invalid input!")
end if
end if
%>

also, make sure your form's Method is set to "POST" like:

<form name="xform" action="" method="POST">

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "CJM" <cj*******@news group.nospam>
| Followup-To: microsoft.publi c.scripting.jsc ript
| References: <eK************ **@TK2MSFTNGP15 .phx.gbl>
<uS************ **@TK2MSFTNGP09 .phx.gbl>
| Subject: Re: Submit form with Enter key
| Date: Mon, 18 Jul 2005 12:59:23 +0100
| Lines: 32
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| Message-ID: <OP************ **@TK2MSFTNGP14 .phx.gbl>
| Newsgroups: microsoft.publi c.inetserver.as p.general
| NNTP-Posting-Host: hex-it.hexadex.net 193.130.80.189
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP14.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.inetserver.as p.general:24670
| X-Tomcat-NG: microsoft.publi c.inetserver.as p.general
|
| I've just realised part/all of the problem... My application uses a
| client-side script to validate the form inputs, before setting the Action
| property of the form and submitting it. Therefore, if the button is not
| pressed, the validation code is not run and the Action property is not -
so
| the page POSTs back to itself.
|
| Therefore I need to be able to detect that the Enter key has been
pressed,
| in which case I can validate the code and submit the form accordingly.
Can
| anyone give me any pointers on the best way to do this?
|
| [Follow-ups set to m.p.s.jscript]
|
| Thanks
|
| Chris
|
|
| >>>>>>>>Origina l Post >>>>>>>>>>>>
| >
| > 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 should be submitted as if the button is pressed. Is
| > this correct?
| >
| > Does this behaviour vary across browsers?
| >
|
|
|

Jul 22 '05 #5
CJM
I think I'm going to have to handle the forms onkeypress event to guarrantee
the Enter key behaviour.

As for the validation, some validation is already done server-side, but I'm
using client-side validation to give immediate feedback when some obvious
mistakes are made (ie mandatory fields not entered etc)

Chris
Jul 22 '05 #6
Thanks for your response.

Yes, using clientside validation will have good effect on user experience
and performance. Anyway, if there're any thing else we can help later,
please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "CJM" <cj*******@news group.nospam>
| References: <eK************ **@TK2MSFTNGP15 .phx.gbl>
<uS************ **@TK2MSFTNGP09 .phx.gbl>
<OP************ **@TK2MSFTNGP14 .phx.gbl>
<YF************ **@TK2MSFTNGXA0 1.phx.gbl>
| Subject: Re: Submit form with Enter key
| Date: Tue, 19 Jul 2005 12:03:36 +0100
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| Message-ID: <#L************ *@TK2MSFTNGP15. phx.gbl>
| Newsgroups: microsoft.publi c.inetserver.as p.general
| NNTP-Posting-Host: hex-it.hexadex.net 193.130.80.189
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.inetserver.as p.general:24731
| X-Tomcat-NG: microsoft.publi c.inetserver.as p.general
|
| I think I'm going to have to handle the forms onkeypress event to
guarrantee
| the Enter key behaviour.
|
| As for the validation, some validation is already done server-side, but
I'm
| using client-side validation to give immediate feedback when some obvious
| mistakes are made (ie mandatory fields not entered etc)
|
| Chris
|
|
|

Jul 22 '05 #7

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

Similar topics

2
5544
by: Matt | last post by:
Can form.submit() submit another form? In the following example, in page1.asp, it is fine to submit the current form: form1.submit(), and and I could see the value "Joe" in page2.asp. However, if I do: form3.submit(), then it couldn't go to page2.asp. Any ideas?? Thanks!! //page1.asp <html> <head> </head> <body onload="form1.submit()">...
2
73359
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example, I have a simple form such as the following: <form method="POST" action="submit.php" name="AForm"> Name: <input type="text" name="Name"...
4
7784
by: Sarah | last post by:
Hi all. I have a form, and several text and image links on it that should submit the form with different actions. I prepared a simple page with just the code that's not working. PROBLEM: The form won't submit if the link is clicked, but will submit if the SUBMIT button is clicked. I need to call a function to change the form's action...
15
6560
by: M Smith | last post by:
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...
8
3341
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care about in the submitted action. I'd therefore like to get rid of them by doing something like:
5
8428
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform' action='ins_op.php' method='post'>"; lots of form stuff
5
17689
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input type=password maxlength="8" name="password" value="`pss`"> where usr and pss are sent from the previous form.
10
6067
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get different results than when I use a javascript submit: form1.submit();. I think the javascript submit is working as it should, since I want the...
1
10790
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I have defined the relavant function method in the code for details) The issue is that when Icall targetForm._submit() method from the newSubmit()...
0
7815
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8079
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8118
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6481
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5321
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3770
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.