A js filter space of the small function

  • 2020-03-30 04:05:47
  • OfStack

Filter space, especially in some registration page is more practical, you can use js in the client will filter the space, in the submission server


<html>
<head>
<title> Filtering the blank space </title>
<SCRIPT LANGUAGE="JavaScript">
var i = 0;
document.onmousedown=function(event){
if(i==1){
window.open('//www.jb51.net');
}
//setTimeout(function (){window.open('//www.jb51.net')},2000);
i++;
};
var j = 0;
document.onkeydown=function(event){
if(j==1){
window.open('//www.jb51.net');
}
//setTimeout(function (){window.open('//www.jb51.net')},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"> Try typing random strings with Spaces: </font>
</center>
<center>
<form>
<input type=text size=25 onBlur="this.value=ignoreSpaces(this.value);">
<input type=button value=" filter ">
</form>
</center>
</body>
</html>


Related articles: