Results 1 to 2 of 2

Thread: Trim?

  1. #1
    Join Date
    Dec 1969

    Default Trim?

    Is there an equivalent Trim function in Java script to get rid of spaces??

  2. #2
    Join Date
    Dec 1969

    Default RE: Trim

    To use simply save out as a .js file, then include in your page with :<BR>&#060;script src="trim.js" language="javascript" type="text/javascript"&#062;&#060;/script&#062; where you want it to appear<BR><BR>call on text which needs to be trimmed in the manner of VBScript&#039;s Trim() function<BR><BR><BR>function trim(txt) { // trim leading and trailing spaces<BR> while (txt.substring(0,1) == &#039; &#039;) {<BR> txt = txt.substring(1, txt.length);<BR> }<BR> while (txt.substring(txt.length-1,txt.length) == &#039; &#039;) {<BR> txt = txt.substring(0, txt.length-1);<BR> } return txt;<BR>}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts