Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

eliminating whitespace in a string 2

Status
Not open for further replies.

xiaoleiqq

Programmer
Aug 30, 2006
43
US
any command in Javascript can perform this job?

Thanks in advance.
 
Here is a regular expression to remove whitespace:
Code:
...
<input type="text" id="test" value="some    text  string"/>
...
var inputValue = document.getElementById('test').value;
inputValue = inputValue.replace(/\s+/gi,'');
...
You would expect to see "sometextstring" in the variable after doing the regular expression.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
[tt]str_stripped=str_given.replace(/\s/g,"");[/tt]
 
Oh, Thanks very much,

replace is the function i am looking for..:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top