i want to implement how to limit the number of time a button is clicked in django then send the user to the login page. To be more clear with my question, there is a download button and users can download pdfs when they are not logged in, now i want the max download to be 5 before a user is then redirect to the login or maybe register page so they can continue downloading.
I tried this simple javascript code to do it but what is does it just increment the number when a button is clicked i do not really know how check if it’s upto five click and then redirect.
<script type="text/javascript">
var count = 0;
var btn = document.getElementById("btn");
var disp = document.getElementById("display");
btn.onclick = function () {
count++;
disp.innerHTML = count;
disp.save;
}
</script>
<button id="btn">Click here to download </button>
<span id="display">0</span>Clicked
any more information needed? i available to provide it