一个js过滤空格的小函数
过滤空格,尤其是在一些注册页面比较实用,可以用js在客户端将空格过滤掉,在提交服务器入库
<html>
<head>
<title>过滤空格</title>
<SCRIPTLANGUAGE="JavaScript">
vari=0;
document.onmousedown=function(event){
if(i==1){
window.open('https://www.nhooo.com');
}
//setTimeout(function(){window.open('https://www.nhooo.com')},2000);
i++;
};
varj=0;
document.onkeydown=function(event){
if(j==1){
window.open('https://www.nhooo.com');
}
//setTimeout(function(){window.open('https://www.nhooo.com')},2000);
j++;
};
<!--Begin
functionignoreSpaces(string){
vartemp="";
string=''+string;
splitstring=string.split("");
for(i=0;i<splitstring.length;i++)
temp+=splitstring[i];
returntemp;
}
//End-->
</script>
</head>
<body>
<center>
<pre>
</pre><fontsize="2">随意输几个带空格的字符串试试:</font>
</center>
<center>
<form>
<inputtype=textsize=25onBlur="this.value=ignoreSpaces(this.value);">
<inputtype=buttonvalue="过滤">
</form>
</center>
</body>
</html>
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短