473,387 Members | 1,553 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,387 software developers and data experts.

how to submit a form when enter is pressed

RTT
<form id="Form1" method="post" runat="server">
<asp:textbox id="TxtEmail" tabIndex="1" runat="server" Width="272px"
ToolTip="Enter your emailaddress for authentication"></asp:textbox>
<asp:textbox id="TxtPassword" tabIndex="2" runat="server" Width="272px"
ToolTip="Enter your domain password" TextMode="Password"></asp:textbox>
<asp:linkbutton id="BtnLogin" tabIndex="3"
runat="server">Login</asp:linkbutton>
</form>

This is the form as i use it for my user to enter thier login information.
But now they have to click the link in order to log in. Is it possible to
submit the form when 'enter' is pressed (like it's the case with input
type="submit" in standard html forms).

does anyone know how to do this?
Nov 21 '05 #1
2 3545
Hi,

You can use the following code for it:

<input type="submit" style="display:none;">

Also, you can use the foolowing method:

In your HTML code,

<script language="javascript">
function blockEnter(evt)
{

if (evt.keyCode == 13)
{

if (evt.srcElement.tagName=="TEXTAREA")
return true;
return false;
}
}

</script>

In the page's codebehind, add this code to the page's prerender event:

TextBox1.Attributes.Add("onKeyDown", "return blockEnter(event)")

HTH

Mona[Grapecity]


"RTT" <RT*@pandora.be> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
<form id="Form1" method="post" runat="server">
<asp:textbox id="TxtEmail" tabIndex="1" runat="server" Width="272px"
ToolTip="Enter your emailaddress for authentication"></asp:textbox>
<asp:textbox id="TxtPassword" tabIndex="2" runat="server" Width="272px"
ToolTip="Enter your domain password" TextMode="Password"></asp:textbox>
<asp:linkbutton id="BtnLogin" tabIndex="3"
runat="server">Login</asp:linkbutton>
</form>

This is the form as i use it for my user to enter thier login information.
But now they have to click the link in order to log in. Is it possible to
submit the form when 'enter' is pressed (like it's the case with input
type="submit" in standard html forms).

does anyone know how to do this?

Nov 21 '05 #2
RTT,

Set Form1.AcceptButton to the button you want clicket when enter is
pressed.

Nov 21 '05 #3

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

Similar topics

15
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...
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...
5
by: http://links.i6networks.com | last post by:
I want to force the users to click submit to submit the forms. How do I disable "Enter Key" which will submit the form automatically when they entered the data in text field then pressed "enter key"
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...
11
by: Sandra Castellanos | last post by:
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...
5
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
1
by: Alexboy | last post by:
Hello, How do I make ENTER key act as a submit request? As it is now, the user has to actually click "submit" for the form to be submitted (in IE at least). Is there any way to make the...
24
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...
9
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.