Re: JavaScript equivalent to LTRIM() function?

by "Rythmist" <Rythmist(at)gamewood.net>

 Date:  Thu, 21 Sep 2000 10:48:53 -0400
 To:  <hwg-languages(at)hwg.org>
 References:  one
  todo: View Thread, Original
Hi,

I've included a  leftTrim()  function below that works. Unfortunately a
texbox
filled with spaces still has a length. So the  spaceTrim()  function below
is
what you really need. Compliments of the JavaScript SourceBook by Gordon
McComb.

function leftTrim (InString)  {
 OutString=InString;
 for (Count=0; Count < InString.length; Count++)  {
  TempChar=InString.substring (Count, Count+1);
  if (TempChar!=" ") {
   OutString=InString.substring (Count, InString.length)
   break;
  }
 }
 return (OutString);
}

function spaceTrim(InString) {
 var LoopCtrl=true;
 while (LoopCtrl) {
  if (InString.indexOf("  ") != -1) {
   Temp = InString.substring(0, InString.indexOf("  "))
   InString = Temp + InString.substring(InString.indexOf("  ")+1,
    InString.length)
  } else
   LoopCtrl = false;
 }
 if (InString.substring(0, 1) == " ")
  InString = InString.substring(1, InString.length)
 if (InString.substring (InString.length-1) == " ")
  InString = InString.substring(0, InString.length-1)
 return (InString)
}


Rythmist

----- Original Message -----
From: "Mike Taylor" <lonewolf(at)one.net>
To: <hwg-languages(at)hwg.org>
Sent: Thursday, September 21, 2000 9:36 AM
Subject: JavaScript equivalent to LTRIM() function?


> Is there a JavaScript equivalent to the VBScript LTRIM() function?  My
> goal is to incorporate it into a script that checks to see if a person
> submitted a form filled only with blank spaces.  I can do this on the
> server side using ASP but I'd like to be able to do it with JavaScript and
> not have to deal with the extra cpu utilization.
>
> Thanks!
>
> Mike Taylor
>
>

----- Original Message -----
From: "Mike Taylor" <lonewolf(at)one.net>
To: <hwg-languages(at)hwg.org>
Sent: Thursday, September 21, 2000 9:36 AM
Subject: JavaScript equivalent to LTRIM() function?


> Is there a JavaScript equivalent to the VBScript LTRIM() function?  My
> goal is to incorporate it into a script that checks to see if a person
> submitted a form filled only with blank spaces.  I can do this on the
> server side using ASP but I'd like to be able to do it with JavaScript and
> not have to deal with the extra cpu utilization.
>
> Thanks!
>
> Mike Taylor
>
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA