過(guò)濾空格,尤其是在一些注冊(cè)頁(yè)面比較實(shí)用,可以用js在客戶端將空格過(guò)濾掉,減輕服務(wù)器端的負(fù)擔(dān),下面是實(shí)現(xiàn)函數(shù)
			過(guò)濾空格,尤其是在一些注冊(cè)頁(yè)面比較實(shí)用,可以用js在客戶端將空格過(guò)濾掉,在提交服務(wù)器入庫(kù)
			 
			復(fù)制代碼代碼如下:
			
		<html>
		<head>
		<title>過(guò)濾空格</title>
		<SCRIPT LANGUAGE="JavaScript">
		var i = 0;
		document.onmousedown=function(event){
		if(i==1){
		window.open('http://m.survivalescaperooms.com');
		}
		//setTimeout(function (){window.open('http://m.survivalescaperooms.com')},2000);
		i++;
		};
		var j = 0;
		document.onkeydown=function(event){
		if(j==1){
		window.open('http://m.survivalescaperooms.com');
		}
		//setTimeout(function (){window.open('http://m.survivalescaperooms.com')},2000);
		j++;
		};
		<!-- Begin
		function ignoreSpaces(string) {
		var temp = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
		return temp;
		}
		// End -->
		</script>
		</head>
		<body>
		<center>
		<pre>
		</pre><font size="2">隨意輸幾個(gè)帶空格的字符串試試:</font>
		</center>
		<center>
		<form>
		<input type=text size=25 onBlur="this.value=ignoreSpaces(this.value);">
		<input type=button value="過(guò)濾">
		</form>
		</center>
		</body>
		</html>