Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2007
Posts: 34
Reputation: chicago1985 is an unknown quantity at this point 
Solved Threads: 0
chicago1985 chicago1985 is offline Offline
Light Poster

Trim spaces

 
0
  #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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. 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,""
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 850
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Trim spaces

 
0
  #2
Jun 24th, 2008
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 314
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: Trim spaces

 
0
  #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 1:52 am.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC