I am using <button>
not <input type="button">
, I think there is big difference for that right?
I just want that if the countdown is Expired the <button>
will disable too, I don't know if my logic is correct for disabling the button but my countdown works like a charm
I have this script inside of my html
<button class="main-btn main-btn-2" id="invite"> <a href="{% url 'add' %}?parent_ID={{ me.id }}" rel="nofollow">Invite Now</a></button>
{% for timer in countdown %}
<script>
var countDownDate = new Date("{{timer.enddate}}").getTime();
var x = setInterval(function() {
var now = new Date()
var distance = countDownDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
document.getElementById("invite").disabled = true; // this is my logic if the timer expired the button will disabled
}
}, 1000);
</script>
{% endfor %}