I'm looking for a way to sanitize input that I paste into the browser, is this possible to do with jQuery?
I've managed to come up with this so far:
$(this).live(pasteEventName, function(e) {
// this is where i would like to sanitize my input
return false;
}
Unfortunately my development has come to a screeching hold because of this "minor" issue. I would really make me a happy camper if someone could point me to the right direction.
This code is working for me either paste from right click or direct copy paste
When i paste
Section 1: Labour Cost
it becomes1
in text box.To allow only float value i use this code
It will work fine.
See this example: http://www.p2e.dk/diverse/detectPaste.htm
It essentialy tracks every change with oninput event and then checks if it’s a paste by string comparison. Oh, and in IE there’s an onpaste event. So:
This method uses jqueries contents().unwrap().
After a given timeout scan through all the contents unwrapping tags that don't have the class that you set earlier. Note: This method does not remove self closing tags like
See an example below.
OK, just bumped into the same issue.. I went around the long way
Just a small timeout till .val() func can get populated.
E.