Welcome visitor
* Login
* Register
It is currently May 20th, 2019, 6:33 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 & unblock keys
PostPosted: August 2nd, 2009, 5:27 am 

Posts: 57
Hi, im facing a problem i myself created. I disabled some keys so the user could not use them in relation to the browser functions, like tab, backspace, etc. but now i want to let the user use them but only when he is fillin a form, what then do you think i should do to unblock the keys?

Remember that i want to have the keys blocked when the user is not writing in the form.
<script type="text/javascript">
document.onkeypress = block;
document.onkeydown = block;
function block(e){
if ((e.keyCode == 9) || (e.keyCode == 8)){
return false;}}
</script>

Thanks for all help


Top
 Profile  
 
  Re: block & unblock keys
PostPosted: August 2nd, 2009, 5:52 am 
User avatar

Posts: 112
add a variable to control where the user is var control=false;
<script type="text/javascript">
var control=false;
document.onkeypress = block;
document.onkeydown = block;
function block(e){
if (control==false){
if ((e.keyCode == 9) || (e.keyCode == 8)){
return false;}}}
</script>

and use it in every input field
<input onfocus="control=true;" onblur="control=false;" />


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