String.prototype.trim = function(){
return this.replace(/^( )+|^[\s ]+|( )+$|[\s ]+$/g, "" );
}alert("---"+ " this is a test kwgkwg ".trim() + "---");
return this.replace(/^( )+|^[\s ]+|( )+$|[\s ]+$/g, "" );
}alert("---"+ " this is a test kwgkwg ".trim() + "---");
<!--
String.prototype.trim = function(){
return this.replace(/^( |[\s ])+|( |[\s ])+$/g, "" );
}
alert("---"+ " this is a test kwgkwg ".trim() + "---");
//-->
</script>