C# .NET stop carriage return/enter key submitting the form

V

Veronica Bourke

Hi,

This is really melting my face. I have a .aspx page with a form. I have
submit buttons on the page for different stages. What i really need is
to stop the form submitting when the return/enter key is pressed.

At the moment if you press the enter key it executes the button clicks
which i dont want.

If someone could help i would be mighty grateful.

Thanks
 
V

Veronica Bourke

Thank you all for your replies. I was trying to do it client side from
the start but couldnt seem to get it working. I eventually wrote
something that worked. Its an onkeypress event for the body tag and it
goes a little something like this:

onkeypress='if ((event.which ? event.which : event.keyCode) == 13) {
event.keyCode = 0; }'

thanks again :)
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top