Welcome visitor
* Login
* Register
It is currently March 19th, 2019, 4:51 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  block submit onenter
PostPosted: August 6th, 2009, 5:36 am 

Posts: 22
i have this code to block the enter key and force the user to submit the form only clicking the submitbutton, but its not working out
<script type="text/javascript">
document.onkeyup = validateEnter;
function validateEnter(e){
if (e.keyCode == 13){return false;}}
</script>

please help


Top
 Profile  
 
  Re: block submit onenter
PostPosted: August 6th, 2009, 5:52 am 
User avatar

Posts: 56
It isnt working because you are validating the event after it takes place. you need to do it when it is happening
<script type="text/javascript">
document.onkeypress = validateEnter;
document.onkeydown = validateEnter;
function validateEnter(e){
if (e.keyCode == 13){return false;}}
</script>
Note that it may not work in internet explorer


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron