Js过滤空格的代码(附演示截图)
js过滤空格的代码。
<head>
<title>过滤空格-www.jquerycn.cn</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- 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">请输入几个带空格的字符串:</font>
</center>
<center>
<form>
<input type=text size=25 onBlur="this.value=ignoreSpaces(this.value);">
<input type=button value="开始过滤">
</form>
</center>
</body>
</html>
演示截图如下:
您可能感兴趣的文章:
js去掉空格的代码
js 禁止文本框输入空格的代码
Js过滤空格的代码(附演示截图)
js去掉字符串的空格或换行符(附相关正则介绍)
js实现trim函数实例代码
js trim函数 js去空格函数与正则
js过滤json特殊字符
学习使用dedecms5.6、5.7文章自动排版插件
js 汉字转拼音的代码
js去空格键 js过滤特殊字符