Geeks With Blogs
.net alternatives by Michel Grootjans January 2011 Entries
Disable pasting in a textbox using jQuery
I had fun writing this one My current client asked me to allow users to paste text into textboxes/textareas, but that the pasted text should be cleaned from '<...>' tags. Here's what we came up with: $(":input").bind('paste', function(e) { var el = $(this); setTimeout(function() { var text = $(el).val(); $(el).val(text.replace(/<... '')); }, 100); }) ; This is so simple, I'm amazed. The first part just binds a function to the paste operation applied to any input declared on the ......

Posted On Thursday, January 27, 2011 5:35 PM

Copyright © Michel Grootjans | Powered by: GeeksWithBlogs.net