如题
在JSP页面得到的这个字符串,如何去掉前后空格?

解决方案 »

  1.   


    String.prototype.trim=function(.){return this.replace(/(^\s*)|(\s*$)/g, "");}
    alert(document.getElementByID('aaa').value..trim())
      

  2.   

    上面是删除所有空格以及不显示的字符的
    这个是仅删除空格:
    String.prototype.rtrimblank=function(){return this.replace(/([.\w]*)[ ]+$/,"$1");}
    lert(document.getElementByID('aaa').value..trim())
      

  3.   

    lert(document.getElementByID('aaa').value..trim())
    --------->
    alert(document.getElementByID('aaa').value.trim())