Hi there,
I have a search function on my web site and am trying to figure why this code does not work. The search function needs to accept numbers 0 to 9, letters a to z, cap letters A to Z, spaces, no spaces, and dashes. Right now the function accepts all but am having problems with search term that contains numbers and letters.
For example, one of the search term in the database is: W12-543-TR-G5-2001
So when a user searches for that particular data, entering "W12-543-TR-G5-2001" or "W12543TRG52001" should render the results. My current codes is not accepting these terms.
string searchterm= "";
for (int i = 0; i < _keyword.Length; i++)
{
if ((_keyword >= 'a' && _keyword <= 'z') || (_keyword >= 'A' && _keyword <= 'Z') || (_keyword >= '0' && _keyword <= '9') || _keyword == ' ' || _keyword == '-')
{
searchterm+= _keyword;
}
}
_keyword = searchterm;
Any help or suggestions is greatly appreciated!
I have a search function on my web site and am trying to figure why this code does not work. The search function needs to accept numbers 0 to 9, letters a to z, cap letters A to Z, spaces, no spaces, and dashes. Right now the function accepts all but am having problems with search term that contains numbers and letters.
For example, one of the search term in the database is: W12-543-TR-G5-2001
So when a user searches for that particular data, entering "W12-543-TR-G5-2001" or "W12543TRG52001" should render the results. My current codes is not accepting these terms.
string searchterm= "";
for (int i = 0; i < _keyword.Length; i++)
{
if ((_keyword >= 'a' && _keyword <= 'z') || (_keyword >= 'A' && _keyword <= 'Z') || (_keyword >= '0' && _keyword <= '9') || _keyword == ' ' || _keyword == '-')
{
searchterm+= _keyword;
}
}
_keyword = searchterm;
Any help or suggestions is greatly appreciated!