Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there an equivalent to "trim" function in Javascript?

Status
Not open for further replies.

alexfrumkin

Programmer
Mar 27, 2000
4
0
0
US
I need to check if the input type text is empty. I can check for emtpy string like in form.txtName.value==&quot;&quot;, but what if someone enters a space or two into it? in VB I would do trim(form.txtName.value)=&quot;&quot;; How do do it using Javascript?<br><br>Thank you for your time and effort.<br><br>Alex
 
&nbsp;&nbsp;&nbsp;&nbsp;Hmmm...wouldn't it be relatively simple to just have a <FONT FACE=monospace>while...loop</font> JavaScript function that just checks the first character of the string agains a space & deletes it if it is...then do your empty-string checking?<br>&nbsp;&nbsp;&nbsp;&nbsp;The <FONT FACE=monospace>while...loop</font> function should work well to replace the &quot;trim&quot; function you were speaking of :) <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= shared.freeservers.com/searchmaster.html>SearchMaster Interface...11-in-1</a><br>Wanting to learn Assembler; please e-mail me any tutorials or links for it that are useful to you :)
 
I hate to RTFM you, but this is something that is too simple to answer.&nbsp;&nbsp;Go to <A HREF=" TARGET="_new"> and look up charAt, indexOf, and some other ones.&nbsp;&nbsp;This should give you the information you're looking for. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top