Gu wrote on 14 mei 2005 in comp.lang.javascript
:
Try this:
<input onKeyPress="return(event.keyCode!=13)"> thanks in advance for any eventual help
eventual like in event.keyCode? ;-}
hmm.. well, you code works, thanks for that, in preventing the form to
submit, but how can i use it for triggering a function when enter is
pressed? the current code is:
onKeyPress="if(event.keyCode==13){invia();}"
This has been told zillions of times in this NG,
and is available in the archive.
onKeyPress="if(event.keyCode==13){invia();return false}"
If you want both the execution of invia()
and the prevention of submission.
Try:
onKeyPress=
"if(event.keyCode==13){alert('You pressed enter');return false}"
Or
onKeyPress=
"if(event.keyCode==13){return confirm('Do you really want submission?')}"
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)