473,888 Members | 1,378 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 3111
"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
5555
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()"> //OK!
2
73387
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" length="20"><br> Age: 15 <a href="age.php">change age</a><br> <input type="submit" name="submit"...
4
7799
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 according to user's input before it is submitted.
15
6593
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 only way I can submit is to click the submit button. Here is a simplified version of my code that I...
8
3378
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
8458
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
17722
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
6099
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 server to process an __EVENTTARGET posting. When I click the submit button, it does not process the...
1
10844
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() function the page I get an 'Object doesn't support this property or method' error I am using IE...
0
9961
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9800
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11185
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3252
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.