Posted by Ed Jay on 12/10/05 23:02
Ed Jay <edMbj@aes-intl.com> wrote:
>"Jonathan N. Little" <lws4art@centralva.net> wrote:
>
>>Ed Jay wrote:
>>> Leif K-Brooks <eurleif@ecritters.biz> wrote:
>>>
>>>
>>>>Ed Jay wrote:
>>>>
>>>>>Is there a method to prevent submitting a form when the user presses the
>>>>>Return key?
>>>>
>>>>Change your browser settings.
>>>
>>>
>>> Thank you. Now, how do I do it on my page so that visitors don't have to
>>> be told to change their browser settings?
>>>
>>Will need javascript but Google is your friend:
>>
>>http://www.google.com/search?hl=en&q=kill+enter+key+forms&btnG=Google+Search
>>
>>Other alternative, which you should have anyway, is server validation
>>that all required fields are supplied, else return to form with some
>>error description.
>
>Thanks a bunch.
Jonathan,
I found the following script...
var isNS =document.appName=="Netscape"?true:false;
var isIE =document.all?true:false;
function keyHandler(e)
{
var _ret=true;
var _char=isIE?event.keyCode:e.which;
alert("key press:" + _char);
if(_char==13) /* enter key */
_ret=false; /* kill event bubler */
return _ret;
}
if(isNS)document.captureEvents(Event.KEYPERSS);/*for NS4*/
window.onkeypress=keyHandler;
How do I call or initiate it? (What is 'e'?)
--
Ed Jay (remove M to respond by email)
[Back to original message]
|