Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search form "Required number of characters"

Status
Not open for further replies.

n0795

Programmer
Jul 30, 2001
136
US
I have a search form which searches a database field and displays the data on a page my database has 10000 lines so i want to make a user enter at least 3 letters.before they can search.
right now they can just hit search and it will disply all of them.or just put "a" and it will show all titles will "a" in them.
Any help would be great.
 
You need to use something like the LEN function. It will tell you how long the string is that they entered.

If LEN(strString) < 3 THEN
Response.Write &quot;You need to enter 3 characters.&quot;
ELSE
'... do processing



END IF

I hope that helps, I'm not sure if thats what you were asking. But thats how I interpreted it.

shorty
 
I assume i need to do

strString = Request.Form (&quot;name of input box&quot;)
If LEN(strString)< 3 THEN
Response.Write &quot;You need to enter at least 3 Characters&quot;
ELSE
END IF

'if all was good it should continue on with the results
Does this look right?
Thanks for responding
 
Yeah that looks right to me.

But you state you are using a input box? Or are you using a text field from the previous page?

If you are using a text field, I know it will work, but I'm not sure about a text box (thats javascript). So I dont know how you could tie the functionality in w/ the vbscript.

-shorty
 
Yeh its a search box which looks for that data in a data base but the problem is the data base has 10,000 entries in it so i need to stop them entering less than 3 characters
Or the page goes on forever.
 
Then that would be your answer. Use the LEN function.

:)

Let us know if that works!

 
Guess im doing something wrong it isnt working
I have tried adding this.
I do put this code on the page where my form will be posted to ?
form = /search.asp
posted to = results.asp

So i put this at the top of results.asp

strString = trim(cstr(Request.form(&quot;Name&quot;)))


If LEN(strString)< 3 THEN
Response.Write &quot;You need to enter at least 3 Character&quot;
ELSE

END IF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top