Javascript去掉字符串前后空格
function String.prototype.trim(){
return this.toString().replace(/^s+|s+$/g,"");
}
=====================================
<script language=Javascript>
function String.prototype.Trim() {return this.replace(/(^s*)|(s*$)/g,"");}
function String.prototype.Ltrim(){return this.replace(/(^s*)/g, "");}
function String.prototype.Rtrim(){return this.replace(/(s*$)/g, "");}
var str = " Trim ";
alert(str.Trim());
</script>
=====================================
返回去掉字符串前后逗号的值
onblur='this.value=this.value.toString().replace(/(^\,*)|(\,*$)/g,"")'