The easiest way is to take the entire contents of the textarea, remove the newlines using a regular expression, and replace the contents with the new string. The difficulty is listening for the "pasting" event, which is especially difficult when the user has dragged text in or used the mouse's context menu. There is a newish "onpaste" event, but it is unsupported across browsers. So you can use "onpaste" but you will also have to use onkeyup (for ctrl+v) and onchange (for context menu paste).