Начало
Формы
Проигнорируйте Места
Удаляет места из переменной последовательности в пределах подлинника или от ввода данных пользователем в текстовое окно.
Before: String = x xx xxx xxxx
After: String =
Or, try entering a string with spaces in this box.
JavaScript Forms: Проигнорируйте Места
<!-- TWO STEPS TO INSTALL IGNORE SPACES: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <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> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <center> <pre> Before: String = x xx xxx xxxx<br> After: String = <script language="JavaScript"> document.write(ignoreSpaces("x xx xxx xxxx")); </script> </pre> </center> <!-- Or, here is another example, in a form --> <p> <center> Or, try entering a string with spaces in this box. <form> <input type=text size=25 onBlur="this.value=ignoreSpaces(this.value);"> <input type=button value="Ok"> </form> </center> <!-- Script Size: 1.30 KB -->