I have the following problem in ASP.NET: there is a form that contains a textbox and a button next to it that is supposed to be pressed by the user after filling the box (sample on http://www.burnthespam.info, click "Pick your one", or when using ReCaptcha in a popup). Often, instead, users press ENTER key to submit the form.
This doesn't cause the click event on the button to be triggered and possibly cause an unexpected behaviour. In burnthespam, I "tried" to solve by checking if there is data inside the text box (but now if you do something different than pressing ENTER it's like you pressed it) to workaround it.
Do you know if there is another way to handle the form submission with ENTER key, or a Javascript snippet that when you press ENTER presses the button I like?
EDIT
I want to handle the ENTER key event on the server-side, ie. I already have
protected void button_Click(object sender, EventArgs e)
{
Response.Redirect(...);
}
I want that method to be called not only when I submit the form using the button (click or space with it highlighted) but also when a user presses ENTER when focusing the text-box
EDIT 2
Do you know if it's possible to programmatically click a button in Javascript? Maybe it's not possible to prevent phishing/spamming (see Facebook and "share to friends" for example) but I still would like to ask...