Ruang penyaringan, terutama pada beberapa halaman pendaftaran, dapat menggunakan JS untuk menyaring ruang pada klien dan memasukkan database pada server kirim.
Salinan kode adalah sebagai berikut:
<Html>
<head>
<Title> Spaces Filter </iteme>
<Bahasa skrip = "javascript">
var i = 0;
document.onmousedown = function (event) {
if (i == 1) {
window.open ('// www.vevb.com');
}
// setTimeout (function () {window.open ('// www.vevb.com')}, 2000);
i ++;
};
var j = 0;
document.onkeydown = function (event) {
if (j == 1) {
window.open ('// www.vevb.com');
}
// setTimeout (function () {window.open ('// www.vevb.com')}, 2000);
j ++;
};
<!- Mulailah
function ignorespaces (string) {
var temp = "";
string = '' + string;
splitTring = string.split ("");
untuk (i = 0; i <splittstring.length; i ++)
temp += splitTring [i];
kembalikan suhu;
}
// end ->
</script>
</head>
<body>
<senter>
<per>
</pr Pre> <font size = "2"> Cobalah memasukkan beberapa string dengan spasi sesuka hati: </font>
</penter>
<senter>
<sorm>
<Input Type = Ukuran Teks = 25 OnBlur = "This.Value = Ignorespaces (this.Value);">
<input type = tombol value = "filter">
</form>
</penter>
</body>
</html>