User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 425,893 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,974 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 349 | Replies: 2
Reply
Join Date: Nov 2007
Posts: 25
Reputation: chicago1985 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
chicago1985 chicago1985 is offline Offline
Light Poster

Trim spaces

  #1  
Jun 24th, 2008
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: 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,""
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 770
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 63
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Master Poster

Re: Trim spaces

  #2  
Jun 24th, 2008
Reply With Quote  
Join Date: Aug 2006
Location: Noida, India
Posts: 158
Reputation: Luckychap is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 17
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Junior Poster

Re: Trim spaces

  #3  
Jun 25th, 2008
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.
Last edited by Luckychap : Jun 25th, 2008 at 12:52 am.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC