Submit on ENTER

G

Guest

Hi,

I'm running into this problem. I want to enable user to submit the form if
'ENTER' is pressed.

The form has two text boxes and a linkbutton.

This is how the code looks like
<BODY onkeydown="javascript:submitForm();">
<form id="Form1" method="post" runat="server">
....
<asp:textbox id="field1" runat="server"></asp:textbox>
<asp:textbox id="field2" runat="server"></asp:textbox>
<asp:linkbutton id="Btn1" runat="server" >Submit</asp:linkbutton>
</form>
</BODY>
....
<SCRIPT language=javascript>
function submitTheForm()
{
if (event.keyCode == 13)
{
__doPostBack("Btn1","");
}
}
</SCRIPT>

Pls ignore any typos. The form submits fine, but there is a sound played on
submit like as if there was an error and I feel its annoying.

Any recommendations/solutions?

Thnx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top