Trim space in Javascript

Results 1 to 2 of 2

Thread: Trim space in Javascript

  1. #1
    Join Date
    Dec 1969

    Default Trim space in Javascript

    Please letme know if there is a LTRIM,RTRIM Functions in Javascript. Apologies for posting this question here.<BR><BR>thanks in advance<BR><BR>regards<BR>king

  2. #2
    Join Date
    Dec 1969

    Default RE: Trim space in Javascript

    u can try this...<BR><BR>&#060;script language="JavaScript"&#062;&#060;!--<BR>function trim(strText) { <BR> // this will get rid of leading spaces <BR> while (strText.substring(0,1) == &#039; &#039;) <BR> strText = strText.substring(1, strText.length);<BR><BR> // this will get rid of trailing spaces <BR> while (strText.substring(strText.length-1,strText.length) == &#039; &#039;)<BR> strText = strText.substring(0, strText.length-1);<BR><BR> return strText;<BR>} <BR>//--&#062;&#060;/script&#062;<BR><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