473,704 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ENTER key to submit forms

Hello,

I want to know what I have to do to make the enter key to submit forms. I
read in another newsgroup that inserting an html hidden text box made the
trick, and it actually does, but in my page I have more than one web control
that have their independient "forms" (in the .NET environment, it makes it
to be just one). And I need that, if the user is, say, writing the keywords
to perform a search, the enter key submits this form, but if he is writing
his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC
Nov 18 '05 #1
11 2144
Sandra,

I've created a javascript component with some commonly used javascripts in
it. One of them does exactly what you are looking for.

The component is free, comes with a help file, and the entire projects
source code is available on my web site: www.aboutfortunate.com. Just click
on the code library link and then click on the "Javascript " button in the
menu on the left.

Even if you don't want to use the entire component the code you need to
create your own is in the project.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I
read in another newsgroup that inserting an html hidden text box made the
trick, and it actually does, but in my page I have more than one web control that have their independient "forms" (in the .NET environment, it makes it
to be just one). And I need that, if the user is, say, writing the keywords to perform a search, the enter key submits this form, but if he is writing
his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC

Nov 18 '05 #2
Hi,

Thank you very much for the code, but I still have one problem, and it is
that .NET is the one that builds the form, and it always gives it the name
of the page, for example if the page is Default.aspx, the name of the form
will be FormDefault. These "forms" I have are in web controls, and they are
included in many different pages. So I can't use the name of the form like
that.... Is there anything like document.forms( 0).thebutton?

Thanks again and bye

SC
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:eV******** *****@tk2msftng p13.phx.gbl...
Sandra,

I've created a javascript component with some commonly used javascripts in
it. One of them does exactly what you are looking for.

The component is free, comes with a help file, and the entire projects
source code is available on my web site: www.aboutfortunate.com. Just click on the code library link and then click on the "Javascript " button in the
menu on the left.

Even if you don't want to use the entire component the code you need to
create your own is in the project.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I read in another newsgroup that inserting an html hidden text box made the trick, and it actually does, but in my page I have more than one web

control
that have their independient "forms" (in the .NET environment, it makes it to be just one). And I need that, if the user is, say, writing the

keywords
to perform a search, the enter key submits this form, but if he is writing his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC


Nov 18 '05 #3
Sorry, ignore the previous message, I was just being stupid.

SC
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:eV******** *****@tk2msftng p13.phx.gbl...
Sandra,

I've created a javascript component with some commonly used javascripts in
it. One of them does exactly what you are looking for.

The component is free, comes with a help file, and the entire projects
source code is available on my web site: www.aboutfortunate.com. Just click on the code library link and then click on the "Javascript " button in the
menu on the left.

Even if you don't want to use the entire component the code you need to
create your own is in the project.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I read in another newsgroup that inserting an html hidden text box made the trick, and it actually does, but in my page I have more than one web

control
that have their independient "forms" (in the .NET environment, it makes it to be just one). And I need that, if the user is, say, writing the

keywords
to perform a search, the enter key submits this form, but if he is writing his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC


Nov 18 '05 #4
I'm sorry, could you please tell me how to attach this eventhandler to my
textboxes? I am working with <asp:textbox> . does it work with them?
Sorry :'(

SC
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I
read in another newsgroup that inserting an html hidden text box made the
trick, and it actually does, but in my page I have more than one web control that have their independient "forms" (in the .NET environment, it makes it
to be just one). And I need that, if the user is, say, writing the keywords to perform a search, the enter key submits this form, but if he is writing
his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC

Nov 18 '05 #5
Sandra,

No problem! :-)

It's pretty easy. Once you've dragged the component onto the page switch to
the code behind page.

If you didn't change the default name of the component when it was placed on
the page you would refer to it as: Javascript1

And you can attach it to as many text boxes as you want like this:

'---Page is the page object literally type "Page" there.
'---Textbox1 is the id of your text box.
'---Button1 is the id of the button you want to fire when the enter key is
' pressed while in this text box.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
End Sub

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:Oi******** ******@TK2MSFTN GP10.phx.gbl...
I'm sorry, could you please tell me how to attach this eventhandler to my
textboxes? I am working with <asp:textbox> . does it work with them?
Sorry :'(

SC
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I read in another newsgroup that inserting an html hidden text box made the trick, and it actually does, but in my page I have more than one web

control
that have their independient "forms" (in the .NET environment, it makes it to be just one). And I need that, if the user is, say, writing the

keywords
to perform a search, the enter key submits this form, but if he is writing his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC


Nov 18 '05 #6
Being stupid again. It worked, thanks a lot :'(
SC
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I
read in another newsgroup that inserting an html hidden text box made the
trick, and it actually does, but in my page I have more than one web control that have their independient "forms" (in the .NET environment, it makes it
to be just one). And I need that, if the user is, say, writing the keywords to perform a search, the enter key submits this form, but if he is writing
his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC

Nov 18 '05 #7
Does it work if the user has the autocomplete enabled? In the page I added
the eventhandler, if I have autocomplete enabled, and I select an item from
the things with which I had filled that textbox before and I hit enter (just
as I always do), then it just does nothing, the form goes cleared and the
buttons don't work anymore.
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:O%******** ********@TK2MSF TNGP12.phx.gbl. ..
Sandra,

No problem! :-)

It's pretty easy. Once you've dragged the component onto the page switch to the code behind page.

If you didn't change the default name of the component when it was placed on the page you would refer to it as: Javascript1

And you can attach it to as many text boxes as you want like this:

'---Page is the page object literally type "Page" there.
'---Textbox1 is the id of your text box.
'---Button1 is the id of the button you want to fire when the enter key is
' pressed while in this text box.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
End Sub

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:Oi******** ******@TK2MSFTN GP10.phx.gbl...
I'm sorry, could you please tell me how to attach this eventhandler to my
textboxes? I am working with <asp:textbox> . does it work with them?
Sorry :'(

SC
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit
forms. I read in another newsgroup that inserting an html hidden text box made the trick, and it actually does, but in my page I have more than one web control
that have their independient "forms" (in the .NET environment, it
makes it to be just one). And I need that, if the user is, say, writing the

keywords
to perform a search, the enter key submits this form, but if he is writing his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC



Nov 18 '05 #8
Sandra,

It only works if the textbox has focus. That's the way javascript works. If
you don't click in the text box or move the cursor when you use autocomplete
to select something the text box doesn't have focus the autocomplete drop
down does. I have no idea how to attach a javascript to that.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uI******** ******@TK2MSFTN GP09.phx.gbl...
Does it work if the user has the autocomplete enabled? In the page I added
the eventhandler, if I have autocomplete enabled, and I select an item from the things with which I had filled that textbox before and I hit enter (just as I always do), then it just does nothing, the form goes cleared and the
buttons don't work anymore.
"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:O%******** ********@TK2MSF TNGP12.phx.gbl. ..
Sandra,

No problem! :-)

It's pretty easy. Once you've dragged the component onto the page switch to
the code behind page.

If you didn't change the default name of the component when it was placed on
the page you would refer to it as: Javascript1

And you can attach it to as many text boxes as you want like this:

'---Page is the page object literally type "Page" there.
'---Textbox1 is the id of your text box.
'---Button1 is the id of the button you want to fire when the enter key is ' pressed while in this text box.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
End Sub

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:Oi******** ******@TK2MSFTN GP10.phx.gbl...
I'm sorry, could you please tell me how to attach this eventhandler to my textboxes? I am working with <asp:textbox> . does it work with them?
Sorry :'(

SC
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
> Hello,
>
> I want to know what I have to do to make the enter key to submit

forms.
I
> read in another newsgroup that inserting an html hidden text box

made the
> trick, and it actually does, but in my page I have more than one web
control
> that have their independient "forms" (in the .NET environment, it

makes
it
> to be just one). And I need that, if the user is, say, writing the
keywords
> to perform a search, the enter key submits this form, but if he is

writing
> his username and password to login, the enter key submits this other
> one........
>
> Does anyone know how to do this?
>
> Best Regards,
>
> SC
>
>



Nov 18 '05 #9
On a related note, I'm interested in AVOIDING having the form submitted when
a user hits the ENTER key (say just after selecting an Option button). Is
there a way to force the user to click the Submit button instead?

Thanks in advance,
Bill

"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:eV******** *****@tk2msftng p13.phx.gbl...
Sandra,

I've created a javascript component with some commonly used javascripts in
it. One of them does exactly what you are looking for.

The component is free, comes with a help file, and the entire projects
source code is available on my web site: www.aboutfortunate.com. Just click on the code library link and then click on the "Javascript " button in the
menu on the left.

Even if you don't want to use the entire component the code you need to
create your own is in the project.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sandra Castellanos" <sa*****@4brain storm.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
Hello,

I want to know what I have to do to make the enter key to submit forms. I read in another newsgroup that inserting an html hidden text box made the trick, and it actually does, but in my page I have more than one web

control
that have their independient "forms" (in the .NET environment, it makes it to be just one). And I need that, if the user is, say, writing the

keywords
to perform a search, the enter key submits this form, but if he is writing his username and password to login, the enter key submits this other
one........

Does anyone know how to do this?

Best Regards,

SC


Nov 18 '05 #10

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

Similar topics

2
9587
by: ivanhoe | last post by:
All articles and tutorials I've seen on subject of forms say that if there's name and value for submit button(input tag with type="submit"), they'll get submitted along with the rest of the form... but I've just noticed (after debugging my perl script for quite a while :/ ) that it is true only when user clicks on submit, and if form is submitted via hitting enter you don't get name=value for submit buttton...
15
6575
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...
6
3100
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 should be submitted as if the button is pressed. Is this correct? Does this behaviour vary across browsers? Chris
5
2779
by: Dennis Allen | last post by:
Hi. I have a user who wants his form submitted when he presses . Is it possible? If so, how?
5
2941
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 believe to be a huge limitation with ASP.NET and I'm wondering how you have handeled this problem. Let's suppose you have a page where the user can do one of two things: add a "Category", or add a "Movie Title" to an already existing category. ...
3
2976
by: yuelinniao | last post by:
hi, I have got a simple way to make "textarea" support "auto-submit" when pressing Ctrl+Enter, and tested under both IE and Firefox. The common old method is like this: <form name=form2> <textarea onkeydown='if(event.keyCode==13 && event.ctrlKey) return document.form2.submit()'> </textarea> </form>
24
8431
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing validation, of course flushing with the bunch of messages because rest of the fields are empty. I remember I had some pages where wrote the code to go on the next field when pressed the Enter button (Tab like), because it didn't go anywhere at all....
9
10740
by: learning | last post by:
Hi! Here's my situation: I have one textfield with one 'submit' button in PAGE1.PHP. When I click on the 'submit' button I am sent to PAGE2.PHP where I have a "switch" routine that checks which 'submit' button was clicked and directs which instructions to do next. My Problem is this: On PAGE1.PHP, there is only one textfield. After filling in the textfield, most of the time people press the 'ENTER KEY' instead of clicking the submit...
12
6942
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 death and cant find the answer (only hints), except on the 'Experts Exhange' page and you have to pay to get the answer :-( Why is this such a secret in the open source world we live in? Daniel Klein
0
8684
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
9271
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
9134
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...
1
9025
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8975
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
5930
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4438
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...
2
2478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2078
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.