<script language="javascript"> String.prototype.trim=function() { return this.replace(/^\s*|\s*$/g, ''); } String.prototype.ltrim=function() { return this.replace(/^\s*/g, ''); } String.prototype.rtrim=function() { return this.replace(/\s*$/g, ''); } var sf = " This is TEST message "; alert(sf.trim()); </script>
Thursday, June 5, 2008
String Trim() in Javascript
Subscribe to:
Post Comments (Atom)
1 comment:
You can also use
http://rochakchauhan.com/blog/2008/10/10/rochakjs-javascript-class-of-common-functions/
It contains many commonly needed functions for JavaScript including trim();
Post a Comment