I tried to write a function to check key code with JavaScript. It’s working fine for Firefox but not IE. Does anyone know what is going wrong with my code? Please see below code for more details:
function textCheck(e)
{
var e = window.event || e
alert("CharCode value: "+e.charCode)
alert("Character: "+String.fromCharCode(e.charCode))
}
switch your first line of code:
…
…
and see if that helps.
Also, if it is a unicode character try something like the following:
If you’re handling
keydowninstead ofkeypress, then things get a bit more complex… See: http://unixpapa.com/js/key.html