DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Trim spaces (http://www.daniweb.com/forums/thread130993.html)

chicago1985 Jun 24th, 2008 10:57 pm
Trim spaces
 
I want to make sure at least 3 characters are entered into a search field.
For example I dont want this to go by where it has spaces in beginning and space between 2 characters:
   a     b
Is there a regular expression or someway to trim the spaces between the characters so I dont let less than 2 characters get submitted?

Here is one reg expression I tried but it let spaces between characters get entered so less than 3 characters were submitted.

/^\s+|\s+$/g,""

R0bb0b Jun 24th, 2008 11:05 pm
Re: Trim spaces
 
try this one
http://www.xploredotnet.blogspot.com...ing-using.html

Luckychap Jun 25th, 2008 1:52 am
Re: Trim spaces
 
Do it manually. Just loop through the input and remove that character which is equal to <space> from the string and then take first 3 character for the search input string.


All times are GMT -4. The time now is 4:10 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC