js去掉左右空格
引入文件夹js下面stringfunctions.txt这一个js文件
<SCRIPT src="${pageContext.request.contextPath}/js/stringfunctions.txt" type=text/javascript></SCRIPT>
var projectId = fnsTrim(" test String " );
js去掉左右空格
function fnsTrim(Instring)
{
OutString=""
Instring = new String(Instring)
OutString=fnsRtrim(fnsLtrim(Instring))
return(OutString);
}
js去掉右边空格
function fnsRtrim(Instring)
{
OutString=""
Instring = new String(Instring)
for(count=Instring.length;count >0;count--)
{
tempchar=Instring.substring(count,count-1)
if (tempchar != " ")
break;
}
OutString=Instring.substring(0,count);
return(OutString);
}
fs去掉左边空格
function fnsLtrim(Instring)
{
OutString=""
Instring = new String(Instring)
for(count=0;count < Instring.length;count++)
{
tempchar=Instring.substring(count,count+1)
if (tempchar != " ")
break;
}
OutString=Instring.substring(count,Instring.length);
return(OutString);
}