You are here: Re: Stopping 'Submit' by Return Key « HTML « IT news, forums, messages
Re: Stopping 'Submit' by Return Key

Posted by Ed Jay on 12/11/05 00:06

"Jonathan N. Little" <lws4art@centralva.net> wrote:

>Ed Jay wrote:
>
>> 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;
>Notice call ^^^ not in function, that initialies it.
>>
>> How do I call or initiate it? (What is 'e'?)
>>
>
>The 'event'
>
>http://www.google.com/search?hl=en&q=javascript+event+handling&btnG=Google+Search

Thanks again for the help, and for your patience with this js newbie.

--
Ed Jay (remove M to respond by email)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация