Home  »  Code Snippets  »  Java Script  »

Remove all blank space from a string using javascript

 Posted By : Manoranjan SahooPosted Date : 24/08/2011 03:00:48 PM Category : Java Script Points : 3

Sometimes we need to remove all spaces from an entered string in client side. Now question is, how can we remove all ocurrances of blank spaces?

To handle client side processing we can use javascript.

check below code to remove all blank space from a string :

Code :

function removeBlankSpace(text)

    return text.replace(/^\s+|\s+$/g, ''); 

here we use regular expression to detect all ocurrances of blank space.


No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.