Script Categories













Forms >>> Ignore Spaces.

Removes spaces from a string variable within a script or from user input into a text box. Several different uses are shown on the script example page.

Before:  String = x xx xxx xxxx
After: String =
Or, try entering a string with spaces in this box.

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- 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>
<pre>
Before:  String = x xx xxx xxxx<br>
After:  String = <script language="JavaScript">
document.write(ignoreSpaces("x xx xxx xxxx"));
</script>
</pre>
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>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©