IT Certificaions

Google Cloud Platform

Wednesday, August 3, 2011

trim() function Java Script


Use these function in Java Script body :
----------------------------------------------------------------------------------------------------
function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function TestTrimString(){
     var testString="  Hello!  "
    document.write("String before  triming:" + testString );  
    document.write("String after     triming:" + trim(testString) );
}

------------------------------------------------------------------------------------------------------