From: DavidC on
I have an asp.net web page with the javascript below at the top of the page.
This works great as a user hitting the <enter> key is not "posted" and
subsitutes the tab key. However, when the user lands on the submit button
(called BtnSave) I want the <enter> key to act as normal. Does anyone know a
way to do this? Thanks.

<script type="text/javascript">
document.onkeydown = doKey;

function doKey(e) {
if (event.keyCode == 13) {
event.keyCode = 9;
return event.keyCode;
}
}
</script>


--
David
From: Alexey Smirnov on
On Mar 4, 3:42 pm, DavidC <dlch...(a)lifetimeinc.com> wrote:
> I have an asp.net web page with the javascript below at the top of the page.
> This works great as a user hitting the <enter> key is not "posted" and
> subsitutes the tab key.  However, when the user lands on the submit button
> (called BtnSave) I want the <enter> key to act as normal.  Does anyone know a
> way to do this?  Thanks.
>
>     <script type="text/javascript">
>         document.onkeydown = doKey;
>
>         function doKey(e) {
>             if (event.keyCode == 13) {
>                 event.keyCode = 9;
>                 return event.keyCode;
>             }
>         }
>     </script>
>
> --
> David

What happens if you add an event handler directly to the button?

onkeypress="..." onClick="..."
From: DavidC on
Javascript is not my strong suit, but I added onkeypress="togglenter();" to
my button and the js function below and it did not work. When I pressed
<enter> when on the button it just issued a TAB to the next control. Can you
spot what I am doing wrong? Thanks.

function togglenter() {
if (event.keyCode == 13) {
event.keyCode = 13;
return event.keyCode;
}
}

--
David


"Alexey Smirnov" wrote:

> On Mar 4, 3:42 pm, DavidC <dlch...(a)lifetimeinc.com> wrote:
> > I have an asp.net web page with the javascript below at the top of the page.
> > This works great as a user hitting the <enter> key is not "posted" and
> > subsitutes the tab key. However, when the user lands on the submit button
> > (called BtnSave) I want the <enter> key to act as normal. Does anyone know a
> > way to do this? Thanks.
> >
> > <script type="text/javascript">
> > document.onkeydown = doKey;
> >
> > function doKey(e) {
> > if (event.keyCode == 13) {
> > event.keyCode = 9;
> > return event.keyCode;
> > }
> > }
> > </script>
> >
> > --
> > David
>
> What happens if you add an event handler directly to the button?
>
> onkeypress="..." onClick="..."
> .
>
 | 
Pages: 1
Prev: asp.net/AJAX samples site
Next: datagrid & css