<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>
如下代码加入HTML的<body>区:
<form method="post" action="...">
<input type=text size=25 onBlur="this.value=ignoreSpaces(this.value);" name="text">
<input type=submit value="Ok" name="button">
</form>