Posted By

DaveChild on 09/11/08


Tagged

trim


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

letosword
artificialkid


JavaScript Trim String


 / Published in: JavaScript
 

  1. function trim(strText) {
  2. while('' + strText.charAt(0) == ' ') {
  3. strText = strText.substring(1, strText.length);
  4. }
  5. while('' + strText.charAt(strText.length-1)==' ') {
  6. strText = strText.substring(0, strText.length-1);
  7. }
  8. return strText;
  9. }

Report this snippet  

You need to login to post a comment.