js 除去多余空格

上一篇 / 下一篇  2012-08-17 16:09:19 / 个人分类:web

<html>
<SCRIPT. LANGUAGE="JavaScript">
<!--//
function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" "); //双引号之间是个空格;
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}
//-->
</script> 
<head>
<meta. http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>html-中国站长站
请输入的几个字符(带空格):<input type=text size=25 nBlur="this.value=ignoreSpaces(this.value);" name="text">
<input type=button value="Ok" name="button">
</form> 
</body>
</html>

TAG:

 

评分:0

我来说两句

Open Toolbar