Sep 11, 2006 #1 xiaoleiqq Programmer Joined Aug 30, 2006 Messages 43 Location US any command in Javascript can perform this job? Thanks in advance.
Sep 11, 2006 1 #2 BabyJeffy Programmer Joined Sep 10, 2003 Messages 4,189 Location GB 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 http://www.codecouch.com/jeff/blog/http://www.coedit.co.uk/[/tt] What is Javascript? FAQ216-6094 Upvote 0 Downvote
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 http://www.codecouch.com/jeff/blog/http://www.coedit.co.uk/[/tt] What is Javascript? FAQ216-6094
Sep 11, 2006 1 #3 tsuji Technical User Joined Jul 25, 2001 Messages 10,675 Location US [tt]str_stripped=str_given.replace(/\s/g,"");[/tt] Upvote 0 Downvote
Sep 11, 2006 Thread starter #4 xiaoleiqq Programmer Joined Aug 30, 2006 Messages 43 Location US Oh, Thanks very much, replace is the function i am looking for.. Upvote 0 Downvote