user4858416
user4858416

Reputation:

Get rid of spaces after search

I've just created a small search engine.. It works fine, but, whenever I search something up with a space on the end; it shows all contents that are in the database? How do I make it so that when people have a space at the end of their input field, it doesn't include that space. Thanks :)

Upvotes: 2

Views: 36

Answers (2)

Alex Tartan
Alex Tartan

Reputation: 6836

Use trim on the filter input.

Php: http://php.net/trim

or

Javascript: http://www.w3schools.com/jsref/jsref_trim_string.asp

Upvotes: 2

Zee
Zee

Reputation: 8488

Use trim() to trim spaces.

 str.trim() //Where str is the value of search field

Upvotes: 1

Related Questions