ASP.NET 2 Enter Key and master page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I'm using framework 2 and web site application with master page and more
than 30 pages used master. I have users come from desktop application who
like to hit Enter every time they entered some things in the textbox. I would
like to disable the Enter Key for this application. Any ideas how to disable
enter key for the whole application.

Thanks.
 
Add following attribute to the BODY tag of the masterpage:

onkeydown="javascript:if(event.keyCode==13){event.keyCode=9;}"

You should get something like this:

<body onkeydown="javascript:if(event.keyCode==13){event.keyCode=9;}">
....
</body>

It will change ENTER key behavoiur - it will work as TAB key.
 
Thank you very much. It's working beautiful.

But that's a horrible solution.

Enter = form submit is a basic function of a web browser. This isn't an
application issue, it's a user training issue.

Disabling the enter key may placate the uneducated users, but it's going to
infuriate any power user and also makes your site that more inaccessible.

-Darrel
 
Back
Top