glkubs
asked on
Is it possible to alter the charCode received during a keypress or keydown events
Can javascript alter the character value received by a keypress event? keypress can filter out characters by returning true or false, but the question is can it Alter the character returned for display in the textbox?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alex,
Thank you for an almost perfect solution... I'm using jquery, so for some reason I had to change the evt.cancelBubble to use evt.preventDefault(); Otherwise, I got the original character and the one I was adding! (simple lower to upper case at the moment).
Thank you... This makes filtering user input easy!
Thank you for an almost perfect solution... I'm using jquery, so for some reason I had to change the evt.cancelBubble to use evt.preventDefault(); Otherwise, I got the original character and the one I was adding! (simple lower to upper case at the moment).
Thank you... This makes filtering user input easy!
seriously?!? ;-)input.value += ",";
I had to change the evt.cancelBubble to use evt.preventDefault();
But you can :
event.preventDefault();
append an other character of your choice
Ahem...
But you can :
event.preventDefault();
append an other character of your choice
Ahem...
Btw: You should really provide a little bit more information that might guide the asker to a suitable solution ;-)
But you can :
event.preventDefault();
append an other character of your choice