replace
var s = $(this).val(); while (s.indexOf("\n") > -1) s = s.replace("\n"," "); $(this).val(s);
You can use RegExp with g flag. var mystring = "this,is,a,test" mystring.replace(/,/g , "newchar");