Hi,
I have a form which searches a database of names and attributes.
It has a textfield where users enter one or more words to describe what they're searching for. The script explodes the user-entered word or words into an array, then loops through the array to search for each one individually.
On the outside chance that someone hits the spacebar more than once between words, or puts more than one space at the end of their entry, the script performs a search for the empty space(s) in addition to the words, and returns ALL the entries in the database, like so:
Matches for word1:
Name
Name
Name
Matches for :
(displays ALL names)
I have tried MANY things to eliminate this problem. I've tried using regexps to identify non-word characters and unset them, and regexps to convert them into asterisks, then delete (unset) the asterisks. I tried to identify the html spacebar character entity, but it didn't work. I've tried trim and chop, with limited results.
When I implemented some of these methods, I would do a display test to see of they were working, and they appeared to, but if I pass any altered or filtered array to the search script, the extraneous spaces apparently are not getting removed.
Do I need to use Javascript or vB code? I've searched everywhere I can think of and can't find any reference to this problem.
Any help is appreciated.