Jump to content
  • 1

Limit the number of search by user?




I have set up a search form with Caspio.

Lets assume there are 2 types of users: those who pay and those who use the service for free.


Is there any way to limit the daily number of searches which the free user can run (say to 3 or 5 searches per day), while the users who are paying can run as many searches as they want daily,


Thanks for your help !

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1

Only 2 Datapages Required (No autosubmit hidden page) Solution.

Ive tested and created a working model of a search

which restricts the search based on:

1) Within 24 hours  :  allowed

2) Maximum searches : 5


Its slightly tricky but works beautifully .

It requires

1) setting up the tables correctly,

2) creating a view  

3) and some javascript code in the submit datapage.


Demo here



user : guest@guest.com

pass : guest


Thanks ~







Link to comment
Share on other sites

  • 0
On 23/01/2017 at 6:35 PM, TexterVaid said:

Im guessing this is what you would have to do. 



Create 4 fields in a table


-datetime field ("logindatetime" of user)

-SearchCount field (Integer)

-PaidUser ? (Yes/No)



Every time a FreeUser logs in:

-stamp his UserID in the UserID field

- stamp the current datetime in the "logindatetime" field.


Everytime a FreeUser completes a search 

-Increase the SearchCount with an increment of 1


With javascript and/or Calculatedfield everytime a User Logs In 



lastlogindatetime= get last  logindatetime from table which is within 24 hours  (Use calculated fields) 


validlogintime=  current time - 24 hours


If  currenttime <= validlogindatetime then Free User will be permitted to Search



2)  If lastlogindatetime  < 24 hours AND PaidUser= No  AND  SearchCount < 5 then

then allow search

else if PaidUser=Yes

then allow search

else Do not allow to search


Hope this helps.



Calculated Fields


Hey there. So tried to do it. I created my table, but I do not know where to input the Javascript ... :S

Link to comment
Share on other sites

  • 0
2 hours ago, TWIRED said:


Add A Header & Footer to Your DataPage.

Javascript is generally put in the footer of the DataPage

Thanks a lot !


When you say "

Every time a FreeUser logs in:

-stamp his UserID in the UserID field

- stamp the current datetime in the "logindatetime" field.


Everytime a FreeUser completes a search 

-Increase the SearchCount with an increment of 1



Do you mean that I will have to do that manually everytime?

Link to comment
Share on other sites

  • 0

<script type="text/javascript">

var maxsearchesallowed=5;

var counter=0;
var counter="[@field:DummyCount#]";

var paiduser="[@field:DummyPaidUser^]";

var searchpermitted=document.getElementById("EditRecordDummySearchPermitted").value;
//alert("searchpermitted= "+searchpermitted);

//----------------------today date format---

var today = new Date();
var dd = today.getDate();
//alert("todays date= " + dd);
var mm = today.getMonth()+1; //January is 0!
//alert("todays month= " + mm);

var yyyy = today.getFullYear();


var today = mm+'/'+dd+'/'+yyyy;

//today=new Date(today);

var searchdate=document.getElementById("EditRecordDummyUserSearchDate").value;


function myFunction() {
//alert("today=  "+today);
//alert("searchdate= " + searchdate);
//alert("paiduser= "+paiduser);

if((today => searchdate) && (paiduser=="No" && Number(counter) < Number(maxsearchesallowed) ) )
alert("allow to search");


alert("sorry, you have exceeded your quota!");
return false;




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...