[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.frontpage.programming

Disable "Enter" key in a form

Anthony

4/5/2004 8:02:00 AM

Hello again everybody,

Since i know the experts on frontpage reside here, i feld free to post
another question.
Here it is, How do i disable the "Enter" on a page were people fill in a
form.
Lots of people try to 'jump' to the next field in my form by using the
'enter' key.
Problem is that this key is behaving the same as the 'Submit' button
I can not use validation on all textfields cause some of them can be left
empty
by visitors.
Any help will be very much appreciated (again)


5 Answers

Kevin Spencer

4/5/2004 12:37:00 PM

0

function captureKey(e) {
var k = document.all? window.event.keyCode:e.which;
return k != 13;
}
document.onkeypress = captureKey;
if (document.layers) document.captureEvents(Event.KEYPRESS);

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anthony" <sodeju2000@hotmail.com> wrote in message
news:c4r3pm$hbm$1@news2.tilbu1.nb.home.nl...
> Hello again everybody,
>
> Since i know the experts on frontpage reside here, i feld free to post
> another question.
> Here it is, How do i disable the "Enter" on a page were people fill in a
> form.
> Lots of people try to 'jump' to the next field in my form by using the
> 'enter' key.
> Problem is that this key is behaving the same as the 'Submit' button
> I can not use validation on all textfields cause some of them can be left
> empty
> by visitors.
> Any help will be very much appreciated (again)
>
>


Anthony

4/7/2004 7:11:00 PM

0

Thanks Kevin so far, but can you tell me where on my
page i put this 'code' please.
I tried lots of things but negative results, Don't i have to
put tags somewhere ?
Thnx Again.


"Kevin Spencer" <kevin@takempis.com> wrote in message
news:ewe3MswGEHA.3816@TK2MSFTNGP10.phx.gbl...
> function captureKey(e) {
> var k = document.all? window.event.keyCode:e.which;
> return k != 13;
> }
> document.onkeypress = captureKey;
> if (document.layers) document.captureEvents(Event.KEYPRESS);
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Anthony" <sodeju2000@hotmail.com> wrote in message
> news:c4r3pm$hbm$1@news2.tilbu1.nb.home.nl...
> > Hello again everybody,
> >
> > Since i know the experts on frontpage reside here, i feld free to post
> > another question.
> > Here it is, How do i disable the "Enter" on a page were people fill in a
> > form.
> > Lots of people try to 'jump' to the next field in my form by using the
> > 'enter' key.
> > Problem is that this key is behaving the same as the 'Submit' button
> > I can not use validation on all textfields cause some of them can be
left
> > empty
> > by visitors.
> > Any help will be very much appreciated (again)
> >
> >
>
>


Eoin Miller

4/7/2004 9:19:00 PM

0

Put it anywhere between the <body> and </body> tags on the page.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anthony" <sodeju2000@hotmail.com> wrote in message
news:c51jo7$e0s$1@news3.tilbu1.nb.home.nl...
> Thanks Kevin so far, but can you tell me where on my
> page i put this 'code' please.
> I tried lots of things but negative results, Don't i have to
> put tags somewhere ?
> Thnx Again.
>
>
> "Kevin Spencer" <kevin@takempis.com> wrote in message
> news:ewe3MswGEHA.3816@TK2MSFTNGP10.phx.gbl...
> > function captureKey(e) {
> > var k = document.all? window.event.keyCode:e.which;
> > return k != 13;
> > }
> > document.onkeypress = captureKey;
> > if (document.layers) document.captureEvents(Event.KEYPRESS);
> >
> > --
> > HTH,
> > Kevin Spencer
> > .Net Developer
> > Microsoft MVP
> > Big things are made up
> > of lots of little things.
> >
> > "Anthony" <sodeju2000@hotmail.com> wrote in message
> > news:c4r3pm$hbm$1@news2.tilbu1.nb.home.nl...
> > > Hello again everybody,
> > >
> > > Since i know the experts on frontpage reside here, i feld free to post
> > > another question.
> > > Here it is, How do i disable the "Enter" on a page were people fill in
a
> > > form.
> > > Lots of people try to 'jump' to the next field in my form by using the
> > > 'enter' key.
> > > Problem is that this key is behaving the same as the 'Submit' button
> > > I can not use validation on all textfields cause some of them can be
> left
> > > empty
> > > by visitors.
> > > Any help will be very much appreciated (again)
> > >
> > >
> >
> >
>
>


arno

4/8/2004 12:51:00 PM

0

Hi Kevin,

your code also deletes ENTER in "textareas". Is there a workaround for this?

I'd wrap your function with something like: if I am in
document.myform.field "my textarea" then do nothing, otherwise ignore ENTER.
However, I do not know how I can find out what the "active" field of the
form is.

> function captureKey(e) {
******if active field is not "my textarea then
> var k = document.all? window.event.keyCode:e.which;
> return k != 13;
> }
> document.onkeypress = captureKey;
> if (document.layers) document.captureEvents(Event.KEYPRESS);
*******else do nothing (= allow ENTER)

best regars

arno


arno

4/14/2004 10:51:00 AM

0

Hi Anthony,

> Lots of people try to 'jump' to the next field in my form by using the
> 'enter' key.

I found a simple way to make "enter" jump to the next field instead of
sending the form:
http://javascript.internet.com/forms/enter-key-...

it says basically to use
onKeyDown="if(event.keyCode==13) event.keyCode=9;"
where you want to disable enter=send.

eg. for your address field:

<FORM METHOD="POST">
Address: <INPUT TYPE="TEXT" onKeyDown="if(event.keyCode==13)
event.keyCode=9;"><BR>
<INPUT TYPE="submit" Value="Ok">
<INPUT TYPE="reset" Value="Cancel">
</FORM>


regards

arno