Reply
how do you prevent form-submission with enter key?
Old 08-27-2004, 09:37 AM how do you prevent form-submission with enter key?
johanesw's Avatar
Extreme Talker

Posts: 174
Location: If I told you that, I'm afraid I'd have to kill you!
Hey guys! If you make a form and there's a textfield or some kind. When you type something into the textfield and press enter, the form will submit...Is there any way to prevent this?

thanks for any help

johanesw is offline
Reply With Quote
View Public Profile Visit johanesw's homepage!
 
When You Register, These Ads Go Away!
Old 08-27-2004, 10:07 AM
QiSoftware's Avatar
Skilled Talker

Posts: 62
Location: U.S.
Yes, look into the onBlur() event handler...
QiSoftware is offline
Reply With Quote
View Public Profile Visit QiSoftware's homepage!
 
Old 08-27-2004, 10:30 AM
Unknown.

Posts: 1,693
Add this javascript to the head of your page..

HTML Code:
<script language="javascript">
function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
</script>
Theres no need to call the function it works for the entire page..

--James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to how do you prevent form-submission with enter key?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11223 seconds with 12 queries