Home  »  Articles  »  Java Script  »

How to remove white space from a string in javascript?

 Posted By : Manoranjan SahooPosted Date : 15/10/2010 08:28:12 AM Category : Java Script Points : 2

I am giving a simple technique to remove white spaces from a string in javascript.

Follow below code to Trim

function RemoveSpace(txtbox)
{
    var Alphabet = / /i;
    var name = txtbox.value;
    while (name.search(Alphabet) > -1)
    {
        if (name.search(Alphabet) > -1)
        {
            name = name.replace(" ", "");
        }
    }
    txtbox.value = name;
}

Thank You.

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