tags:

views:

5267

answers:

4

HTML code:

<input type="text" id="secrecy" name="secrecy" size="3" maxlengh="3" />Days

Jquery code:

$('#secrecy').keyup(function(){
alert("ok");    
});

Error message:

The 'charCode' property of a keyup event should not be used. The value is meaningless.

The Jquery code doesn't work.When I input something into "secrecy", an alert doesn't come out.What's wrong?

+1  A: 

That's not an error; it's a warning.

It's probably generated by code within jQuery that copies the properties of the event object to a wrapper that gets passed to your handler.

You should ignore it.

SLaks
I can not ignore it. When I input something in “secrecy", an alert doesn't come out. The Jquery code doesn't work.
Steven
Then something else is wrong. Are you running the code before the page is fully loaded? Can you post a demo?
SLaks
The other part of Jquery code works fine.
Steven
+2  A: 

I tested your code and didn't see the error you mentioned, could you provide code that reproduces this error?

I was thinking that it could just be the browser you are using...

keyCode and charCode

The two properties are keyCode and charCode. Put (too) simply, keyCode says something about the actual keyboard key the user pressed, while charCode gives the ASCII value of the resulting character. These bits of information need not be the same; for instance, a lower case 'a' and an upper case 'A' have the same keyCode, because the user presses the same key, but a different charCode because the resulting character is different.

Explorer and Opera do not support charCode. However, they give the character information in keyCode, but only onkeypress. Onkeydown and -up keyCode contains key information.

From quirksmode site, but I don't see you using either in your example code. Are you using them?

fudgey
+1  A: 

Are you waiting to bind the event until the Dom is ready?

Something like this might help:

$(document).ready(function(){
  $('#secrecy').keyup(function(){
    alert("ok");    
  });
});
samg
Thank you,@samg.
Steven
@samg... I am having the same problem and my code is indeed inside `$(document).ready(function() {...});` and it still gives me the error. Any other suggestions?
Hristo
I have the exact same problem here :( (Firefox 3.6.8, Ubuntu 10.04)
Fu86
A: 

i've a trouble too. I assign event to but there not work!

$(document).ready(function(){ $("#test ul").bind("keyup",function(){ alert('Handler for .keyup() called.'); });

})

tuan.nguyenminh