I was thinking to a function that check the key value pressed, and accept only the most common characters, canc, enter, ... because i need it only for basic ascii character set (not ñ, č, ch开发者_StackOverflowinese chars, ...).
Or function that after every keyup checks if value has changed.
But really jQuery doesn't have an event handler for this situation?
Oh, it should be cross-borwser.
You could try canceling keys, but then they might just paste. Or might find a way to set the value via script. The best thing to do is to validate that the value doesn't have special characters before they're sent to the server (or otherwise acted upon).
var oldval = $('textarea').val();
$('textarea').live('mouseover', function() {
if($(this).val() != oldval) {
//do your thing here
oldval = $(this).val(); //reassign oldval
}
});
This will activate on mouseover and do whatever you want it to if the new value is not the same as the old one. I haven't tested it but I think it should also cover pasting.
精彩评论