penders - 10:22 am on Jan 27, 2012 (gmt 0)
onpaste is not a recognized event of textarea so here is the correct version
onpaste is non-standard, but has reasonable browser support and should have worked. However, you only need the paste event if using the INPUT element, since the TEXTAREA does not have an issue with pasting multi-line text.
var newStr = str.slice(0, -1)
But this blindly chops off the last character whether it is a comma or not! It's easiest to use another regular expression to do this...
var newStr = str.replace(/(^,+)|(,+$)/g,'');