Posted By

Memphys on 10/04/06


Tagged

javascript trim


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

tylerhall
luman
rnrleachryan


trim function


 / Published in: JavaScript
 

  1. <script language="JavaScript" type="text/JavaScript">
  2. <!--
  3. function trim(s) {
  4. while (s.substring(0,1) == ' ') {
  5. s = s.substring(1,s.length);
  6. }
  7. while (s.substring(s.length-1,s.length) == ' ') {
  8. s = s.substring(0,s.length-1);
  9. }
  10. return s;
  11. }
  12. //-->
  13. </script>

Report this snippet  

You need to login to post a comment.