views:

580

answers:

2

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 ñ, č, chinese 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.

A: 

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).

Ken Browning
I didn't think about paste problem. You are right about that. But i need an event that fires only when the textarea value is changed.
Manuel Bitto
A: 
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.

bobsoap