This topic is locked

Require X amount of chars to search??

2/22/2005 1:04:04 PM
ASPRunnerPro General questions
author

Hi, I am a registered user of ASP Runner, I love it.. thanks!
My client would like to know if we can require at least 4 characters in the search box in order to perform a search... the reason being we have lots of semi-confidential information and do not want large lists that are easy to export after doing a search. requiring at least 3 or 4 chars in the search box will limit the amount of results.. is this possible? does my example make sense? thank you so much!

Sergey Kornilov admin 2/24/2005

Here is the simple example how you can require visitors to enter four or more characters into a search box on the list page. My changes are in bold:

<input type=button class=button name="SearchButton" value="Search"

onClick="java script: document.forms.frmAdmin.action.value = 'Search';

 if (document.forms.frmAdmin.SearchFor.value.length<4) alert('Enter four characters or more'); else document.forms.frmAdmin.submit();"
>


Please note that this code will work only when Search button is clicked. If you like this also to work when Enter button is pressed you need to add similar code to search form onSubmit event.

500183 3/2/2005